idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
158,300
public void deleteMergeRequestNote ( Object projectIdOrPath , Integer mergeRequestIid , Integer noteId ) throws GitLabApiException { if ( mergeRequestIid == null ) { throw new RuntimeException ( "mergeRequestIid cannot be null" ) ; } if ( noteId == null ) { throw new RuntimeException ( "noteId cannot be null" ) ; } Response . Status expectedStatus = ( isApiVersion ( GitLabApi . ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "merge_requests" , mergeRequestIid , "notes" , noteId ) ; }
Delete the specified merge request s note .
168
8
158,301
public Stream < Tag > getTagsStream ( Object projectIdOrPath ) throws GitLabApiException { return ( getTags ( projectIdOrPath , getDefaultPerPage ( ) ) . stream ( ) ) ; }
Get a Stream of repository tags from a project sorted by name in reverse alphabetical order .
46
18
158,302
public Tag getTag ( Object projectIdOrPath , String tagName ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "tags" , tagName ) ; return ( response . readEntity ( Tag . class ) ) ; }
Get a specific repository tag determined by its name .
79
10
158,303
public Optional < Tag > getOptionalTag ( Object projectIdOrPath , String tagName ) throws GitLabApiException { try { return ( Optional . ofNullable ( getTag ( projectIdOrPath , tagName ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get an Optional instance holding a Tag instance of a specific repository tag determined by its name .
81
18
158,304
public Tag createTag ( Object projectIdOrPath , String tagName , String ref ) throws GitLabApiException { return ( createTag ( projectIdOrPath , tagName , ref , null , ( String ) null ) ) ; }
Creates a tag on a particular ref of the given project .
50
13
158,305
public Release createRelease ( Object projectIdOrPath , String tagName , String releaseNotes ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "description" , releaseNotes ) ; Response response = post ( Response . Status . CREATED , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "tags" , tagName , "release" ) ; return ( response . readEntity ( Release . class ) ) ; }
Add release notes to the existing git tag .
118
9
158,306
public Release updateRelease ( Object projectIdOrPath , String tagName , String releaseNotes ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "description" , releaseNotes ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "tags" , tagName , "release" ) ; return ( response . readEntity ( Release . class ) ) ; }
Updates the release notes of a given release .
117
10
158,307
public List < User > getUsers ( int page , int perPage ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( page , perPage , customAttributesEnabled ) , "users" ) ; return ( response . readEntity ( new GenericType < List < User > > ( ) { } ) ) ; }
Get a list of users using the specified page and per page settings .
78
14
158,308
public Pager < User > getUsers ( int itemsPerPage ) throws GitLabApiException { return ( new Pager < User > ( this , User . class , itemsPerPage , createGitLabApiForm ( ) . asMap ( ) , "users" ) ) ; }
Get a Pager of users .
62
7
158,309
public Pager < User > getActiveUsers ( int itemsPerPage ) throws GitLabApiException { GitLabApiForm formData = createGitLabApiForm ( ) . withParam ( "active" , true ) ; return ( new Pager < User > ( this , User . class , itemsPerPage , formData . asMap ( ) , "users" ) ) ; }
Get a Pager of active users .
84
8
158,310
public void blockUser ( Integer userId ) throws GitLabApiException { if ( userId == null ) { throw new RuntimeException ( "userId cannot be null" ) ; } if ( isApiVersion ( ApiVersion . V3 ) ) { put ( Response . Status . CREATED , null , "users" , userId , "block" ) ; } else { post ( Response . Status . CREATED , ( Form ) null , "users" , userId , "block" ) ; } }
Blocks the specified user . Available only for admin .
109
10
158,311
public List < User > getblockedUsers ( int page , int perPage ) throws GitLabApiException { GitLabApiForm formData = createGitLabApiForm ( ) . withParam ( "blocked" , true ) . withParam ( PAGE_PARAM , page ) . withParam ( PER_PAGE_PARAM , perPage ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "users" ) ; return ( response . readEntity ( new GenericType < List < User > > ( ) { } ) ) ; }
Get a list of blocked users using the specified page and per page settings .
127
15
158,312
public User getUser ( int userId ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "with_custom_attributes" , customAttributesEnabled ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "users" , userId ) ; return ( response . readEntity ( User . class ) ) ; }
Get a single user .
91
5
158,313
public Optional < User > getOptionalUser ( int userId ) { try { return ( Optional . ofNullable ( getUser ( userId ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get a single user as an Optional instance .
64
9
158,314
public User getUser ( String username ) throws GitLabApiException { GitLabApiForm formData = createGitLabApiForm ( ) . withParam ( "username" , username , true ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "users" ) ; List < User > users = response . readEntity ( new GenericType < List < User > > ( ) { } ) ; return ( users . isEmpty ( ) ? null : users . get ( 0 ) ) ; }
Lookup a user by username . Returns null if not found .
115
13
158,315
public Optional < User > getOptionalUser ( String username ) { try { return ( Optional . ofNullable ( getUser ( username ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Lookup a user by username and return an Optional instance .
62
12
158,316
public List < User > findUsers ( String emailOrUsername ) throws GitLabApiException { return ( findUsers ( emailOrUsername , getDefaultPerPage ( ) ) . all ( ) ) ; }
Search users by Email or username
45
6
158,317
public Pager < User > findUsers ( String emailOrUsername , int itemsPerPage ) throws GitLabApiException { GitLabApiForm formData = createGitLabApiForm ( ) . withParam ( "search" , emailOrUsername , true ) ; return ( new Pager < User > ( this , User . class , itemsPerPage , formData . asMap ( ) , "users" ) ) ; }
Search users by Email or username and return a Pager
94
11
158,318
public Stream < User > findUsersStream ( String emailOrUsername ) throws GitLabApiException { return ( findUsers ( emailOrUsername , getDefaultPerPage ( ) ) . stream ( ) ) ; }
Search users by Email or username .
46
7
158,319
@ Deprecated public User modifyUser ( User user , CharSequence password , Integer projectsLimit ) throws GitLabApiException { Form form = userToForm ( user , projectsLimit , password , false , false ) ; Response response = put ( Response . Status . OK , form . asMap ( ) , "users" , user . getId ( ) ) ; return ( response . readEntity ( User . class ) ) ; }
Modifies an existing user . Only administrators can change attributes of a user .
90
15
158,320
public void deleteUser ( Object userIdOrUsername , Boolean hardDelete ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "hard_delete " , hardDelete ) ; Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , formData . asMap ( ) , "users" , getUserIdOrUsername ( userIdOrUsername ) ) ; }
Deletes a user . Available only for administrators .
122
10
158,321
public User getCurrentUser ( ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "user" ) ; return ( response . readEntity ( User . class ) ) ; }
Get currently authenticated user .
46
5
158,322
public List < SshKey > getSshKeys ( ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "user" , "keys" ) ; return ( response . readEntity ( new GenericType < List < SshKey > > ( ) { } ) ) ; }
Get a list of currently authenticated user s SSH keys .
74
11
158,323
public List < SshKey > getSshKeys ( Integer userId ) throws GitLabApiException { if ( userId == null ) { throw new RuntimeException ( "userId cannot be null" ) ; } Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "users" , userId , "keys" ) ; List < SshKey > keys = response . readEntity ( new GenericType < List < SshKey > > ( ) { } ) ; if ( keys != null ) { keys . forEach ( key -> key . setUserId ( userId ) ) ; } return ( keys ) ; }
Get a list of a specified user s SSH keys . Available only for admin users .
139
17
158,324
public SshKey getSshKey ( Integer keyId ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "user" , "keys" , keyId ) ; return ( response . readEntity ( SshKey . class ) ) ; }
Get a single SSH Key .
61
6
158,325
public Optional < SshKey > getOptionalSshKey ( Integer keyId ) { try { return ( Optional . ofNullable ( getSshKey ( keyId ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get a single SSH Key as an Optional instance .
70
10
158,326
public SshKey addSshKey ( String title , String key ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title ) . withParam ( "key" , key ) ; Response response = post ( Response . Status . CREATED , formData , "user" , "keys" ) ; return ( response . readEntity ( SshKey . class ) ) ; }
Creates a new key owned by the currently authenticated user .
99
12
158,327
public SshKey addSshKey ( Integer userId , String title , String key ) throws GitLabApiException { if ( userId == null ) { throw new RuntimeException ( "userId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title ) . withParam ( "key" , key ) ; Response response = post ( Response . Status . CREATED , formData , "users" , userId , "keys" ) ; SshKey sshKey = response . readEntity ( SshKey . class ) ; if ( sshKey != null ) { sshKey . setUserId ( userId ) ; } return ( sshKey ) ; }
Create new key owned by specified user . Available only for admin users .
158
14
158,328
public List < ImpersonationToken > getImpersonationTokens ( Object userIdOrUsername , ImpersonationState state ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "state" , state ) . withParam ( PER_PAGE_PARAM , getDefaultPerPage ( ) ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "users" , getUserIdOrUsername ( userIdOrUsername ) , "impersonation_tokens" ) ; return ( response . readEntity ( new GenericType < List < ImpersonationToken > > ( ) { } ) ) ; }
Get a list of a specified user s impersonation tokens . Available only for admin users .
155
18
158,329
public ImpersonationToken getImpersonationToken ( Object userIdOrUsername , Integer tokenId ) throws GitLabApiException { if ( tokenId == null ) { throw new RuntimeException ( "tokenId cannot be null" ) ; } Response response = get ( Response . Status . OK , null , "users" , getUserIdOrUsername ( userIdOrUsername ) , "impersonation_tokens" , tokenId ) ; return ( response . readEntity ( ImpersonationToken . class ) ) ; }
Get an impersonation token of a user . Available only for admin users .
114
15
158,330
public Optional < ImpersonationToken > getOptionalImpersonationToken ( Object userIdOrUsername , Integer tokenId ) { try { return ( Optional . ofNullable ( getImpersonationToken ( userIdOrUsername , tokenId ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get an impersonation token of a user as an Optional instance . Available only for admin users .
86
19
158,331
public ImpersonationToken createImpersonationToken ( Object userIdOrUsername , String name , Date expiresAt , Scope [ ] scopes ) throws GitLabApiException { if ( scopes == null || scopes . length == 0 ) { throw new RuntimeException ( "scopes cannot be null or empty" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "name" , name , true ) . withParam ( "expires_at" , expiresAt ) ; for ( Scope scope : scopes ) { formData . withParam ( "scopes[]" , scope . toString ( ) ) ; } Response response = post ( Response . Status . CREATED , formData , "users" , getUserIdOrUsername ( userIdOrUsername ) , "impersonation_tokens" ) ; return ( response . readEntity ( ImpersonationToken . class ) ) ; }
Create an impersonation token . Available only for admin users .
204
12
158,332
public void revokeImpersonationToken ( Object userIdOrUsername , Integer tokenId ) throws GitLabApiException { if ( tokenId == null ) { throw new RuntimeException ( "tokenId cannot be null" ) ; } Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , null , "users" , getUserIdOrUsername ( userIdOrUsername ) , "impersonation_tokens" , tokenId ) ; }
Revokes an impersonation token . Available only for admin users .
125
13
158,333
Form userToForm ( User user , Integer projectsLimit , CharSequence password , Boolean resetPassword , boolean create ) { if ( create ) { if ( ( password == null || password . toString ( ) . trim ( ) . isEmpty ( ) ) && ! resetPassword ) { throw new IllegalArgumentException ( "either password or reset_password must be set" ) ; } } projectsLimit = ( projectsLimit == null ) ? user . getProjectsLimit ( ) : projectsLimit ; String skipConfirmationFeildName = create ? "skip_confirmation" : "skip_reconfirmation" ; return ( new GitLabApiForm ( ) . withParam ( "email" , user . getEmail ( ) , create ) . withParam ( "password" , password , false ) . withParam ( "reset_password" , resetPassword , false ) . withParam ( "username" , user . getUsername ( ) , create ) . withParam ( "name" , user . getName ( ) , create ) . withParam ( "skype" , user . getSkype ( ) , false ) . withParam ( "linkedin" , user . getLinkedin ( ) , false ) . withParam ( "twitter" , user . getTwitter ( ) , false ) . withParam ( "website_url" , user . getWebsiteUrl ( ) , false ) . withParam ( "organization" , user . getOrganization ( ) , false ) . withParam ( "projects_limit" , projectsLimit , false ) . withParam ( "extern_uid" , user . getExternUid ( ) , false ) . withParam ( "provider" , user . getProvider ( ) , false ) . withParam ( "bio" , user . getBio ( ) , false ) . withParam ( "location" , user . getLocation ( ) , false ) . withParam ( "admin" , user . getIsAdmin ( ) , false ) . withParam ( "can_create_group" , user . getCanCreateGroup ( ) , false ) . withParam ( skipConfirmationFeildName , user . getSkipConfirmation ( ) , false ) . withParam ( "external" , user . getExternal ( ) , false ) . withParam ( "shared_runners_minutes_limit" , user . getSharedRunnersMinutesLimit ( ) , false ) ) ; }
Populate the REST form with data from the User instance .
516
12
158,334
public CustomAttribute createCustomAttribute ( final Object userIdOrUsername , final String key , final String value ) throws GitLabApiException { if ( Objects . isNull ( key ) || key . trim ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "Key can't be null or empty" ) ; } if ( Objects . isNull ( value ) || value . trim ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "Value can't be null or empty" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "value" , value ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "users" , getUserIdOrUsername ( userIdOrUsername ) , "custom_attributes" , key ) ; return ( response . readEntity ( CustomAttribute . class ) ) ; }
Creates custom attribute for the given user
201
8
158,335
public CustomAttribute changeCustomAttribute ( final Object userIdOrUsername , final CustomAttribute customAttribute ) throws GitLabApiException { if ( Objects . isNull ( customAttribute ) ) { throw new IllegalArgumentException ( "CustomAttributes can't be null" ) ; } //changing & creating custom attributes is the same call in gitlab api // -> https://docs.gitlab.com/ce/api/custom_attributes.html#set-custom-attribute return createCustomAttribute ( userIdOrUsername , customAttribute . getKey ( ) , customAttribute . getValue ( ) ) ; }
Change custom attribute for the given user
128
7
158,336
public CustomAttribute changeCustomAttribute ( final Object userIdOrUsername , final String key , final String value ) throws GitLabApiException { return createCustomAttribute ( userIdOrUsername , key , value ) ; }
Changes custom attribute for the given user
47
7
158,337
private GitLabApiForm createGitLabApiForm ( ) { GitLabApiForm formData = new GitLabApiForm ( ) ; return ( customAttributesEnabled ? formData . withParam ( "with_custom_attributes" , true ) : formData ) ; }
Creates a GitLabApiForm instance that will optionally include the with_custom_attributes query param if enabled .
62
25
158,338
public User setUserAvatar ( final Object userIdOrUsername , File avatarFile ) throws GitLabApiException { Response response = putUpload ( Response . Status . OK , "avatar" , avatarFile , "users" , getUserIdOrUsername ( userIdOrUsername ) ) ; return ( response . readEntity ( User . class ) ) ; }
Uploads and sets the user s avatar for the specified user .
79
13
158,339
private static Object [ ] convertToObjectArray ( Object obj ) { if ( obj instanceof Object [ ] ) { return ( Object [ ] ) obj ; } int arrayLength = Array . getLength ( obj ) ; Object [ ] retArray = new Object [ arrayLength ] ; for ( int i = 0 ; i < arrayLength ; ++ i ) { retArray [ i ] = Array . get ( obj , i ) ; } return retArray ; }
as there seems be no legal way for casting
95
9
158,340
public static void loadProperties ( String classpathName , Properties toProps ) { Validate . argumentIsNotNull ( classpathName ) ; Validate . argumentIsNotNull ( toProps ) ; InputStream inputStream = PropertiesUtil . class . getClassLoader ( ) . getResourceAsStream ( classpathName ) ; if ( inputStream == null ) { throw new JaversException ( CLASSPATH_RESOURCE_NOT_FOUND , classpathName ) ; } try { toProps . load ( inputStream ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
loads a properties file from classpath using default classloader
134
11
158,341
private static Collection difference ( Collection first , Collection second ) { if ( first == null ) { return EMPTY_LIST ; } if ( second == null ) { return first ; } Collection difference = new ArrayList <> ( first ) ; for ( Object current : second ) { difference . remove ( current ) ; } return difference ; }
Difference that handle properly collections with duplicates .
69
10
158,342
public List < CdoSnapshot > getHistoricals ( GlobalId globalId , CommitId timePoint , boolean withChildValueObjects , int limit ) { argumentsAreNotNull ( globalId , timePoint ) ; return delegate . getStateHistory ( globalId , QueryParamsBuilder . withLimit ( limit ) . withChildValueObjects ( withChildValueObjects ) . toCommitId ( timePoint ) . build ( ) ) ; }
last snapshot with commitId < = given timePoint
95
10
158,343
public Optional < CdoSnapshot > getHistorical ( GlobalId globalId , LocalDateTime timePoint ) { argumentsAreNotNull ( globalId , timePoint ) ; return delegate . getStateHistory ( globalId , QueryParamsBuilder . withLimit ( 1 ) . to ( timePoint ) . build ( ) ) . stream ( ) . findFirst ( ) ; }
last snapshot with commitId < = given date
78
9
158,344
private List < CdoSnapshot > loadMasterEntitySnapshotIfNecessary ( InstanceId instanceId , List < CdoSnapshot > alreadyLoaded ) { if ( alreadyLoaded . isEmpty ( ) ) { return alreadyLoaded ; } if ( alreadyLoaded . stream ( ) . filter ( s -> s . getGlobalId ( ) . equals ( instanceId ) ) . findFirst ( ) . isPresent ( ) ) { return alreadyLoaded ; } return getLatest ( instanceId ) . map ( it -> { List < CdoSnapshot > enhanced = new ArrayList ( alreadyLoaded ) ; enhanced . add ( it ) ; return java . util . Collections . unmodifiableList ( enhanced ) ; } ) . orElse ( alreadyLoaded ) ; }
required for the corner case when valueObject snapshots consume all the limit
166
13
158,345
public SqlRepositoryBuilder withSchema ( String schemaName ) { if ( schemaName != null && ! schemaName . isEmpty ( ) ) { this . schemaName = schemaName ; } return this ; }
This function sets a schema to be used for creation and updating tables . When passing a schema name make sure that the schema has been created in the database before running JaVers . If schemaName is null or empty the default schema is used instead .
45
49
158,346
public Object getPropertyValue ( Property property ) { Validate . argumentIsNotNull ( property ) ; Object val = properties . get ( property . getName ( ) ) ; if ( val == null ) { return Defaults . defaultValue ( property . getGenericType ( ) ) ; } return val ; }
returns default values for null primitives
64
8
158,347
public < C extends Change > List getObjectsByChangeType ( final Class < C > type ) { argumentIsNotNull ( type ) ; return Lists . transform ( getChangesByType ( type ) , input -> input . getAffectedObject ( ) . < JaversException > orElseThrow ( ( ) -> new JaversException ( AFFECTED_CDO_IS_NOT_AVAILABLE ) ) ) ; }
Selects new removed or changed objects
93
7
158,348
public List getObjectsWithChangedProperty ( String propertyName ) { argumentIsNotNull ( propertyName ) ; return Lists . transform ( getPropertyChanges ( propertyName ) , input -> input . getAffectedObject ( ) . < JaversException > orElseThrow ( ( ) -> new JaversException ( AFFECTED_CDO_IS_NOT_AVAILABLE ) ) ) ; }
Selects objects with changed property for given property name
86
10
158,349
public List < Change > getChanges ( Predicate < Change > predicate ) { return Lists . positiveFilter ( changes , predicate ) ; }
Changes that satisfies given filter
28
5
158,350
public List < PropertyChange > getPropertyChanges ( final String propertyName ) { argumentIsNotNull ( propertyName ) ; return ( List ) getChanges ( input -> input instanceof PropertyChange && ( ( PropertyChange ) input ) . getPropertyName ( ) . equals ( propertyName ) ) ; }
Selects property changes for given property name
62
8
158,351
public List < Change > calculateDiffs ( List < CdoSnapshot > snapshots , Map < SnapshotIdentifier , CdoSnapshot > previousSnapshots ) { Validate . argumentsAreNotNull ( snapshots ) ; Validate . argumentsAreNotNull ( previousSnapshots ) ; List < Change > changes = new ArrayList <> ( ) ; for ( CdoSnapshot snapshot : snapshots ) { if ( snapshot . isInitial ( ) ) { addInitialChanges ( changes , snapshot ) ; } else if ( snapshot . isTerminal ( ) ) { addTerminalChanges ( changes , snapshot ) ; } else { CdoSnapshot previousSnapshot = previousSnapshots . get ( SnapshotIdentifier . from ( snapshot ) . previous ( ) ) ; addChanges ( changes , previousSnapshot , snapshot ) ; } } return changes ; }
Calculates changes introduced by a collection of snapshots . This method expects that the previousSnapshots map contains predecessors of all non - initial and non - terminal snapshots .
176
33
158,352
public < T > List < T > filterToList ( Object source , Class < T > filter ) { Validate . argumentsAreNotNull ( filter ) ; return ( List ) unmodifiableList ( items ( source ) . filter ( item -> item != null && filter . isAssignableFrom ( item . getClass ( ) ) ) . collect ( Collectors . toList ( ) ) ) ; }
Returns a new unmodifiable Enumerable with filtered items nulls are omitted .
85
16
158,353
List < JaversProperty > getManagedProperties ( Predicate < JaversProperty > query ) { return Lists . positiveFilter ( managedProperties , query ) ; }
returns managed properties subset
36
5
158,354
public MapContentType getMapContentType ( ContainerType containerType ) { JaversType keyType = getJaversType ( Integer . class ) ; JaversType valueType = getJaversType ( containerType . getItemType ( ) ) ; return new MapContentType ( keyType , valueType ) ; }
only for change appenders
66
5
158,355
public boolean isContainerOfManagedTypes ( JaversType javersType ) { if ( ! ( javersType instanceof ContainerType ) ) { return false ; } return getJaversType ( ( ( ContainerType ) javersType ) . getItemType ( ) ) instanceof ManagedType ; }
is Set List or Array of ManagedClasses
64
10
158,356
public JaversType getJaversType ( Type javaType ) { argumentIsNotNull ( javaType ) ; if ( javaType == Object . class ) { return OBJECT_TYPE ; } return engine . computeIfAbsent ( javaType , j -> typeFactory . infer ( j , findPrototype ( j ) ) ) ; }
Returns mapped type spawns a new one from a prototype or infers a new one using default mapping .
70
20
158,357
public < T extends ManagedType > T getJaversManagedType ( Class javaClass , Class < T > expectedType ) { JaversType mType = getJaversType ( javaClass ) ; if ( expectedType . isAssignableFrom ( mType . getClass ( ) ) ) { return ( T ) mType ; } else { throw new JaversException ( JaversExceptionCode . MANAGED_CLASS_MAPPING_ERROR , javaClass , mType . getClass ( ) . getSimpleName ( ) , expectedType . getSimpleName ( ) ) ; } }
If given javaClass is mapped to expected ManagedType returns its JaversType
126
16
158,358
@ Bean ( name = "JaversFromStarter" ) @ ConditionalOnMissingBean public Javers javers ( ) { logger . info ( "Starting javers-spring-boot-starter-mongo ..." ) ; MongoDatabase mongoDatabase = mongoClient . getDatabase ( mongoProperties . getMongoClientDatabase ( ) ) ; logger . info ( "connecting to database: {}" , mongoProperties . getMongoClientDatabase ( ) ) ; MongoRepository javersRepository = createMongoRepository ( javersMongoProperties , mongoDatabase ) ; return JaversBuilder . javers ( ) . registerJaversRepository ( javersRepository ) . withProperties ( javersMongoProperties ) . withObjectAccessHook ( new DBRefUnproxyObjectAccessHook ( ) ) . build ( ) ; }
from spring - boot - starter - data - mongodb
186
13
158,359
private Diff createAndAppendChanges ( GraphPair graphPair , Optional < CommitMetadata > commitMetadata ) { DiffBuilder diff = new DiffBuilder ( javersCoreConfiguration . getPrettyValuePrinter ( ) ) ; //calculate node scope diff for ( NodeChangeAppender appender : nodeChangeAppenders ) { diff . addChanges ( appender . getChangeSet ( graphPair ) , commitMetadata ) ; } //calculate snapshot of NewObjects if ( javersCoreConfiguration . isNewObjectsSnapshot ( ) ) { for ( ObjectNode node : graphPair . getOnlyOnRight ( ) ) { FakeNodePair pair = new FakeNodePair ( node ) ; appendPropertyChanges ( diff , pair , commitMetadata ) ; } } //calculate property-to-property diff for ( NodePair pair : nodeMatcher . match ( graphPair ) ) { appendPropertyChanges ( diff , pair , commitMetadata ) ; } return diff . build ( ) ; }
Graph scope appender
218
4
158,360
private void addCommitDateInstantColumnIfNeeded ( ) { if ( ! columnExists ( getCommitTableNameWithSchema ( ) , COMMIT_COMMIT_DATE_INSTANT ) ) { addStringColumn ( getCommitTableNameWithSchema ( ) , COMMIT_COMMIT_DATE_INSTANT , 30 ) ; } else { extendStringColumnIfNeeded ( getCommitTableNameWithSchema ( ) , COMMIT_COMMIT_DATE_INSTANT , 30 ) ; } }
JaVers 5 . 0 to 5 . 1 schema migration
114
11
158,361
private void alterCommitIdColumnIfNeeded ( ) { ColumnType commitIdColType = getTypeOf ( getCommitTableNameWithSchema ( ) , "commit_id" ) ; if ( commitIdColType . precision == 12 ) { logger . info ( "migrating db schema from JaVers 2.5 to 2.6 ..." ) ; if ( dialect instanceof PostgresDialect ) { executeSQL ( "ALTER TABLE " + getCommitTableNameWithSchema ( ) + " ALTER COLUMN commit_id TYPE numeric(22,2)" ) ; } else if ( dialect instanceof H2Dialect ) { executeSQL ( "ALTER TABLE " + getCommitTableNameWithSchema ( ) + " ALTER COLUMN commit_id numeric(22,2)" ) ; } else if ( dialect instanceof MysqlDialect ) { executeSQL ( "ALTER TABLE " + getCommitTableNameWithSchema ( ) + " MODIFY commit_id numeric(22,2)" ) ; } else if ( dialect instanceof OracleDialect ) { executeSQL ( "ALTER TABLE " + getCommitTableNameWithSchema ( ) + " MODIFY commit_id number(22,2)" ) ; } else if ( dialect instanceof MsSqlDialect ) { executeSQL ( "drop index jv_commit_commit_id_idx on " + getCommitTableNameWithSchema ( ) ) ; executeSQL ( "ALTER TABLE " + getCommitTableNameWithSchema ( ) + " ALTER COLUMN commit_id numeric(22,2)" ) ; executeSQL ( "CREATE INDEX jv_commit_commit_id_idx ON " + getCommitTableNameWithSchema ( ) + " (commit_id)" ) ; } else { handleUnsupportedDialect ( ) ; } } }
JaVers 2 . 5 to 2 . 6 schema migration
410
11
158,362
private void alterMssqlTextColumns ( ) { ColumnType stateColType = getTypeOf ( getSnapshotTableNameWithSchema ( ) , "state" ) ; ColumnType changedPropertiesColType = getTypeOf ( getSnapshotTableNameWithSchema ( ) , "state" ) ; if ( stateColType . typeName . equals ( "text" ) ) { executeSQL ( "ALTER TABLE " + getSnapshotTableNameWithSchema ( ) + " ALTER COLUMN state VARCHAR(MAX)" ) ; } if ( changedPropertiesColType . typeName . equals ( "text" ) ) { executeSQL ( "ALTER TABLE " + getSnapshotTableNameWithSchema ( ) + " ALTER COLUMN changed_properties VARCHAR(MAX)" ) ; } }
JaVers 3 . 3 . 0 to 3 . 3 . 1 MsSql schema migration
177
18
158,363
@ Override public Object map ( Object sourceEnumerable , Function mapFunction , boolean filterNulls ) { Validate . argumentIsNotNull ( mapFunction ) ; Multimap sourceMultimap = toNotNullMultimap ( sourceEnumerable ) ; Multimap targetMultimap = ArrayListMultimap . create ( ) ; MapType . mapEntrySet ( sourceMultimap . entries ( ) , mapFunction , ( k , v ) -> targetMultimap . put ( k , v ) , filterNulls ) ; return targetMultimap ; }
Nulls keys are filtered
121
5
158,364
private Collection < JaversType > bootJsonConverter ( ) { JsonConverterBuilder jsonConverterBuilder = jsonConverterBuilder ( ) ; addModule ( new ChangeTypeAdaptersModule ( getContainer ( ) ) ) ; addModule ( new CommitTypeAdaptersModule ( getContainer ( ) ) ) ; if ( new RequiredMongoSupportPredicate ( ) . test ( repository ) ) { jsonConverterBuilder . registerNativeGsonDeserializer ( Long . class , new MongoLong64JsonDeserializer ( ) ) ; } jsonConverterBuilder . registerJsonTypeAdapters ( getComponents ( JsonTypeAdapter . class ) ) ; jsonConverterBuilder . registerNativeGsonDeserializer ( Diff . class , new DiffTypeDeserializer ( ) ) ; JsonConverter jsonConverter = jsonConverterBuilder . build ( ) ; addComponent ( jsonConverter ) ; return Lists . transform ( jsonConverterBuilder . getValueTypes ( ) , c -> new ValueType ( c ) ) ; }
boots JsonConverter and registers domain aware typeAdapters
231
14
158,365
private Object reverseCdoIdMapKey ( Cdo cdo ) { if ( cdo . getGlobalId ( ) instanceof InstanceId ) { return cdo . getGlobalId ( ) ; } return new SystemIdentityWrapper ( cdo . getWrappedCdo ( ) . get ( ) ) ; }
InstanceId for Entities System . identityHashCode for ValueObjects
68
14
158,366
private static Bson prefixQuery ( String fieldName , String prefix ) { return Filters . regex ( fieldName , "^" + RegexEscape . escape ( prefix ) + ".*" ) ; }
enables index range scan
44
5
158,367
public static < T > List < T > positiveFilter ( List < T > input , Predicate < T > filter ) { argumentsAreNotNull ( input , filter ) ; return input . stream ( ) . filter ( filter ) . collect ( Collectors . toList ( ) ) ; }
returns new list with elements from input that satisfies given filter condition
60
13
158,368
public static < T > List < T > negativeFilter ( List < T > input , final Predicate < T > filter ) { argumentsAreNotNull ( input , filter ) ; return input . stream ( ) . filter ( element -> ! filter . test ( element ) ) . collect ( Collectors . toList ( ) ) ; }
returns new list with elements from input that don t satisfies given filter condition
69
15
158,369
public QueryBuilder withChangedProperty ( String propertyName ) { Validate . argumentIsNotNull ( propertyName ) ; queryParamsBuilder . changedProperty ( propertyName ) ; return this ; }
Only snapshots which changed a given property .
40
8
158,370
public QueryBuilder withCommitId ( CommitId commitId ) { Validate . argumentIsNotNull ( commitId ) ; queryParamsBuilder . commitId ( commitId ) ; return this ; }
Only snapshots created in a given commit .
42
8
158,371
public QueryBuilder withCommitIds ( Collection < BigDecimal > commitIds ) { Validate . argumentIsNotNull ( commitIds ) ; queryParamsBuilder . commitIds ( commitIds . stream ( ) . map ( CommitId :: valueOf ) . collect ( Collectors . toSet ( ) ) ) ; return this ; }
Only snapshots created in given commits .
75
7
158,372
public QueryBuilder toCommitId ( CommitId commitId ) { Validate . argumentIsNotNull ( commitId ) ; queryParamsBuilder . toCommitId ( commitId ) ; return this ; }
Only snapshots created before this commit or exactly in this commit .
44
12
158,373
public QueryBuilder byAuthor ( String author ) { Validate . argumentIsNotNull ( author ) ; queryParamsBuilder . author ( author ) ; return this ; }
Only snapshots committed by a given author .
35
8
158,374
public static Class < ? > classForName ( String className ) { try { return Class . forName ( className , false , Javers . class . getClassLoader ( ) ) ; } catch ( ClassNotFoundException ex ) { throw new JaversException ( ex ) ; } }
throws RuntimeException if class is not found
61
9
158,375
public static Object newInstance ( Class clazz , ArgumentResolver resolver ) { Validate . argumentIsNotNull ( clazz ) ; for ( Constructor constructor : clazz . getDeclaredConstructors ( ) ) { if ( isPrivate ( constructor ) || isProtected ( constructor ) ) { continue ; } Class [ ] types = constructor . getParameterTypes ( ) ; Object [ ] params = new Object [ types . length ] ; for ( int i = 0 ; i < types . length ; i ++ ) { try { params [ i ] = resolver . resolve ( types [ i ] ) ; } catch ( JaversException e ) { logger . error ( "failed to create new instance of " + clazz . getName ( ) + ", argument resolver for arg[" + i + "] " + types [ i ] . getName ( ) + " thrown exception: " + e . getMessage ( ) ) ; throw e ; } } try { constructor . setAccessible ( true ) ; return constructor . newInstance ( params ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } throw new JaversException ( JaversExceptionCode . NO_PUBLIC_CONSTRUCTOR , clazz . getName ( ) ) ; }
Creates new instance of public or package - private class . Calls first not - private constructor
267
18
158,376
JaversType spawn ( Type baseJavaType ) { try { Constructor c = this . getClass ( ) . getConstructor ( Type . class ) ; return ( JaversType ) c . newInstance ( new Object [ ] { baseJavaType } ) ; } catch ( ReflectiveOperationException exception ) { throw new RuntimeException ( "error calling Constructor for " + this . getClass ( ) . getName ( ) , exception ) ; } }
Factory method delegates to self constructor
95
6
158,377
private String formatMaybeIpv6 ( String address ) { String openBracket = "[" ; String closeBracket = "]" ; if ( address . contains ( ":" ) && ! address . startsWith ( openBracket ) && ! address . endsWith ( closeBracket ) ) { return openBracket + address + closeBracket ; } return address ; }
This isn t very precise ; org . jboss . as . network . NetworkUtils has better implementation but that s in a private module .
78
29
158,378
@ Override public void handleRequest ( HttpServerExchange exchange ) throws Exception { Account account = exchange . getSecurityContext ( ) . getAuthenticatedAccount ( ) ; if ( account != null && account . getPrincipal ( ) instanceof JsonWebToken ) { JsonWebToken token = ( JsonWebToken ) account . getPrincipal ( ) ; PrincipalProducer myInstance = CDI . current ( ) . select ( PrincipalProducer . class ) . get ( ) ; myInstance . setJsonWebToken ( token ) ; } next . handleRequest ( exchange ) ; }
If there is a JWTAccount installed in the exchange security context create
125
16
158,379
public static Options defaultOptions ( ) { return new Options ( HELP , CONFIG_HELP , YAML_HELP , VERSION , PROPERTY , PROPERTIES_URL , SERVER_CONFIG , CONFIG , PROFILES , BIND ) ; }
Default set of options
60
4
158,380
public < T > void put ( Option < T > key , T value ) { this . values . put ( key , value ) ; }
Put a value under a given key .
29
8
158,381
@ SuppressWarnings ( "unchecked" ) public < T > T get ( Option < T > key ) { T v = ( T ) this . values . get ( key ) ; if ( v == null ) { v = key . defaultValue ( ) ; this . values . put ( key , v ) ; } return v ; }
Retrieve a value under a given key .
73
9
158,382
public void applyProperties ( Swarm swarm ) throws IOException { URL propsUrl = get ( PROPERTIES_URL ) ; if ( propsUrl != null ) { Properties urlProps = new Properties ( ) ; urlProps . load ( propsUrl . openStream ( ) ) ; for ( String name : urlProps . stringPropertyNames ( ) ) { swarm . withProperty ( name , urlProps . getProperty ( name ) ) ; } } Properties props = get ( PROPERTY ) ; for ( String name : props . stringPropertyNames ( ) ) { swarm . withProperty ( name , props . getProperty ( name ) ) ; } if ( get ( BIND ) != null ) { swarm . withProperty ( SwarmProperties . BIND_ADDRESS , get ( BIND ) ) ; } }
Apply properties to the system properties .
173
7
158,383
public void applyConfigurations ( Swarm swarm ) throws IOException { if ( get ( SERVER_CONFIG ) != null ) { swarm . withXmlConfig ( get ( SERVER_CONFIG ) ) ; } if ( get ( CONFIG ) != null ) { List < URL > configs = get ( CONFIG ) ; for ( URL config : configs ) { swarm . withConfig ( config ) ; } } if ( get ( PROFILES ) != null ) { List < String > profiles = get ( PROFILES ) ; for ( String profile : profiles ) { swarm . withProfile ( profile ) ; } } }
Apply configuration to the container .
132
6
158,384
public void apply ( Swarm swarm ) throws IOException , ModuleLoadException { applyProperties ( swarm ) ; applyConfigurations ( swarm ) ; if ( get ( HELP ) ) { displayVersion ( System . err ) ; System . err . println ( ) ; displayHelp ( System . err ) ; System . exit ( 0 ) ; } if ( get ( CONFIG_HELP ) != null ) { displayConfigHelp ( System . err , get ( CONFIG_HELP ) ) ; System . exit ( 0 ) ; } if ( get ( YAML_HELP ) != null ) { dumpYaml ( System . err , get ( YAML_HELP ) ) ; System . exit ( 0 ) ; } if ( get ( VERSION ) ) { displayVersion ( System . err ) ; } }
Apply properties and configuration from the parsed commandline to a container .
172
13
158,385
public static CommandLine parse ( Options options , String ... args ) throws Exception { return CommandLineParser . parse ( options , args ) ; }
Parse an array of arguments using specific options .
29
10
158,386
public static ResourceLoader getModuleResourceLoader ( final String rootPath , final String loaderPath , final String loaderName ) { if ( Holder . JAR_FILE != null ) { return new JarFileResourceLoader ( loaderName , Holder . JAR_FILE , Holder . FILE_SYSTEM . getPath ( rootPath , loaderPath ) . toString ( ) ) ; } return ResourceLoaders . createFileResourceLoader ( loaderPath , new File ( rootPath ) ) ; }
Creates a new resource loader for the environment .
100
10
158,387
@ Override public AuthenticationMechanismOutcome authenticate ( HttpServerExchange exchange , SecurityContext securityContext ) { List < String > authHeaders = exchange . getRequestHeaders ( ) . get ( AUTHORIZATION ) ; if ( authHeaders != null ) { String bearerToken = null ; for ( String current : authHeaders ) { if ( current . toLowerCase ( Locale . ENGLISH ) . startsWith ( "bearer " ) ) { bearerToken = current . substring ( 7 ) ; if ( UndertowLogger . SECURITY_LOGGER . isTraceEnabled ( ) ) { UndertowLogger . SECURITY_LOGGER . tracef ( "Bearer token: %s" , bearerToken ) ; } try { identityManager = securityContext . getIdentityManager ( ) ; JWTCredential credential = new JWTCredential ( bearerToken , authContextInfo ) ; if ( UndertowLogger . SECURITY_LOGGER . isTraceEnabled ( ) ) { UndertowLogger . SECURITY_LOGGER . tracef ( "Bearer token: %s" , bearerToken ) ; } // Install the JWT principal as the caller Account account = identityManager . verify ( credential . getName ( ) , credential ) ; if ( account != null ) { JsonWebToken jwtPrincipal = ( JsonWebToken ) account . getPrincipal ( ) ; securityContext . authenticationComplete ( account , "MP-JWT" , false ) ; // Workaround authenticated JWTPrincipal not being installed as user principal // https://issues.jboss.org/browse/WFLY-9212 org . jboss . security . SecurityContext jbSC = SecurityContextAssociation . getSecurityContext ( ) ; Subject subject = jbSC . getUtil ( ) . getSubject ( ) ; jbSC . getUtil ( ) . createSubjectInfo ( jwtPrincipal , bearerToken , subject ) ; RoleGroup roles = extract ( subject ) ; jbSC . getUtil ( ) . setRoles ( roles ) ; UndertowLogger . SECURITY_LOGGER . debugf ( "Authenticated caller(%s) for path(%s) with roles: %s" , credential . getName ( ) , exchange . getRequestPath ( ) , account . getRoles ( ) ) ; return AuthenticationMechanismOutcome . AUTHENTICATED ; } else { UndertowLogger . SECURITY_LOGGER . info ( "Failed to authenticate JWT bearer token" ) ; return AuthenticationMechanismOutcome . NOT_AUTHENTICATED ; } } catch ( Exception e ) { UndertowLogger . SECURITY_LOGGER . infof ( e , "Failed to validate JWT bearer token" ) ; return AuthenticationMechanismOutcome . NOT_AUTHENTICATED ; } } } } // No suitable header has been found in this request, return AuthenticationMechanismOutcome . NOT_ATTEMPTED ; }
Extract the Authorization header and validate the bearer token if it exists . If it does and is validated this builds the org . jboss . security . SecurityContext authenticated Subject that drives the container APIs as well as the authorization layers .
657
46
158,388
protected RoleGroup extract ( Subject subject ) { Optional < Principal > match = subject . getPrincipals ( ) . stream ( ) . filter ( g -> g . getName ( ) . equals ( SecurityConstants . ROLES_IDENTIFIER ) ) . findFirst ( ) ; Group rolesGroup = ( Group ) match . get ( ) ; RoleGroup roles = new SimpleRoleGroup ( rolesGroup ) ; return roles ; }
Extract the Roles group and return it as a RoleGroup
90
13
158,389
public ConfigViewImpl withProperties ( Properties properties ) { if ( properties != null ) { this . properties = properties ; this . strategy . withProperties ( properties ) ; } return this ; }
Supply explicit properties object for introspection and outrespection .
41
13
158,390
private Set < String > getPackagesForScanning ( WARArchive deployment ) { final Set < String > packages = new TreeSet <> ( ) ; if ( indexView != null ) { DotName dotName = DotName . createSimple ( Api . class . getName ( ) ) ; Collection < AnnotationInstance > instances = indexView . getAnnotations ( dotName ) ; instances . forEach ( ai -> { AnnotationTarget target = ai . target ( ) ; if ( target . kind ( ) == AnnotationTarget . Kind . CLASS ) { extractAndAddPackageInfo ( target . asClass ( ) , packages , indexView ) ; } } ) ; // Scan for all top level resources. dotName = DotName . createSimple ( Path . class . getName ( ) ) ; instances = indexView . getAnnotations ( dotName ) ; instances . forEach ( ai -> { AnnotationTarget target = ai . target ( ) ; switch ( target . kind ( ) ) { case CLASS : extractAndAddPackageInfo ( target . asClass ( ) , packages , indexView ) ; break ; case METHOD : extractAndAddPackageInfo ( target . asMethod ( ) . declaringClass ( ) , packages , indexView ) ; break ; default : // Do nothing. Probably log something here? } } ) ; // Reduce the packages to just about what is required. Set < String > tmp = new HashSet <> ( packages ) ; Iterator < String > itr = packages . iterator ( ) ; while ( itr . hasNext ( ) ) { String current = itr . next ( ) ; boolean remove = false ; if ( current . startsWith ( "org.wildfly.swarm" ) ) { remove = true ; } else { // Search through the list to see if a parent package has already been included in the list. for ( String s : tmp ) { if ( s . length ( ) < current . length ( ) && current . startsWith ( s ) ) { remove = true ; break ; } } } if ( remove ) { itr . remove ( ) ; } } } else { // // Existing default behavior. // String packageName = null ; for ( Map . Entry < ArchivePath , Node > entry : deployment . getContent ( ) . entrySet ( ) ) { final ArchivePath key = entry . getKey ( ) ; if ( key . get ( ) . endsWith ( ".class" ) ) { String parentPath = key . getParent ( ) . get ( ) ; parentPath = parentPath . replaceFirst ( "/" , "" ) ; String parentPackage = parentPath . replaceFirst ( ".*/classes/" , "" ) ; parentPackage = parentPackage . replaceAll ( "/" , "." ) ; if ( parentPackage . startsWith ( "org.wildfly.swarm" ) ) { SwaggerMessages . MESSAGES . ignoringPackage ( parentPackage ) ; } else { packageName = parentPackage ; break ; } } } packages . add ( packageName ) ; } return packages ; }
Get the packages that should be scanned by Swagger . This method attempts to determine the root packages by leveraging the IndexView of the deployment . If the IndexView is unavailable then this method will fallback to the scanning the classes manually .
648
47
158,391
public void stop ( ) throws Exception { final CountDownLatch latch = new CountDownLatch ( 1 ) ; this . serviceContainer . addTerminateListener ( info -> latch . countDown ( ) ) ; this . serviceContainer . shutdown ( ) ; latch . await ( ) ; executor . submit ( new Runnable ( ) { @ Override public void run ( ) { TempFileManager . deleteRecursively ( tmpDir ) ; } } ) ; executor . shutdown ( ) ; }
Stops the service container and cleans up all file system resources .
105
13
158,392
public void beforeShutdown ( @ Observes final BeforeShutdown bs ) { monitor . unregisterHealthReporter ( ) ; monitor . unregisterContextClassLoader ( ) ; reporter = null ; reporterInstance . preDestroy ( ) . dispose ( ) ; reporterInstance = null ; }
Called when the deployment is undeployed .
59
10
158,393
void setup ( final Map < String , Object > properties ) { final List < SetupAction > successfulActions = new ArrayList < SetupAction > ( ) ; for ( final SetupAction action : setupActions ) { try { action . setup ( properties ) ; successfulActions . add ( action ) ; } catch ( final Throwable e ) { for ( SetupAction s : successfulActions ) { try { s . teardown ( properties ) ; } catch ( final Throwable t ) { // we ignore these, and just propagate the exception that caused the setup to fail } } throw new RuntimeException ( e ) ; } } }
Sets up the contexts . If any of the setup actions fail then any setup contexts are torn down and then the exception is wrapped and thrown
132
28
158,394
private void resolveDependenciesInParallel ( List < DependencyNode > nodes ) { List < ArtifactRequest > artifactRequests = nodes . stream ( ) . map ( node -> new ArtifactRequest ( node . getArtifact ( ) , this . remoteRepositories , null ) ) . collect ( Collectors . toList ( ) ) ; try { this . resolver . resolveArtifacts ( this . session , artifactRequests ) ; } catch ( ArtifactResolutionException e ) { // ignore, error will be printed by resolve(ArtifactSpec) } }
This is needed to speed up things .
117
8
158,395
public Swarm outboundSocketBinding ( String socketBindingGroup , OutboundSocketBinding binding ) { this . outboundSocketBindings . add ( new OutboundSocketBindingRequest ( socketBindingGroup , binding ) ) ; return this ; }
Add an outbound socket - binding to the container .
53
11
158,396
public Swarm socketBinding ( String socketBindingGroup , SocketBinding binding ) { this . socketBindings . add ( new SocketBindingRequest ( socketBindingGroup , binding ) ) ; return this ; }
Add an inbound socket - binding to the container .
45
11
158,397
public Swarm start ( ) throws Exception { INSTANCE = this ; try ( AutoCloseable handle = Performance . time ( "Thorntail.start()" ) ) { Module module = Module . getBootModuleLoader ( ) . loadModule ( CONTAINER_MODULE_NAME ) ; Class < ? > bootstrapClass = module . getClassLoader ( ) . loadClass ( "org.wildfly.swarm.container.runtime.ServerBootstrapImpl" ) ; ServerBootstrap bootstrap = ( ServerBootstrap ) bootstrapClass . newInstance ( ) ; bootstrap . withArguments ( this . args ) . withBootstrapDebug ( this . debugBootstrap ) . withExplicitlyInstalledFractions ( this . explicitlyInstalledFractions ) . withSocketBindings ( this . socketBindings ) . withOutboundSocketBindings ( this . outboundSocketBindings ) . withUserComponents ( this . userComponentClasses ) . withXmlConfig ( this . xmlConfig ) . withConfigView ( this . configView . get ( true ) ) ; this . server = bootstrap . bootstrap ( ) ; return this ; } }
Start the container .
245
4
158,398
public Swarm stop ( ) throws Exception { if ( this . server == null ) { throw SwarmMessages . MESSAGES . containerNotStarted ( "stop()" ) ; } this . server . stop ( ) ; this . server = null ; Module module = Module . getBootModuleLoader ( ) . loadModule ( CONTAINER_MODULE_NAME ) ; Class < ? > shutdownClass = module . getClassLoader ( ) . loadClass ( "org.wildfly.swarm.container.runtime.WeldShutdownImpl" ) ; WeldShutdown shutdown = ( WeldShutdown ) shutdownClass . newInstance ( ) ; shutdown . shutdown ( ) ; return this ; }
Stop the container first undeploying all deployments .
145
10
158,399
public Swarm deploy ( ) throws IllegalStateException , DeploymentException { if ( this . server == null ) { throw SwarmMessages . MESSAGES . containerNotStarted ( "deploy()" ) ; } if ( ApplicationEnvironment . get ( ) . isHollow ( ) ) { this . server . deployer ( ) . deploy ( getCommandLine ( ) . extraArguments ( ) . stream ( ) . map ( e -> Paths . get ( e ) ) . collect ( Collectors . toList ( ) ) ) ; } else { this . server . deployer ( ) . deploy ( ) ; } return this ; }
Perform a default deployment .
135
6