idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
19,500 | @ Override public Constant getVal ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return groupVal . getVal ( fldname ) ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return fn . value ( ) ; throw new RuntimeException ( "field " + fldname + " not found." ) ; } | Gets the Constant value of the specified field . If the field is a group field then its value can be obtained from the saved group value . Otherwise the value is obtained from the appropriate aggregation function . | 103 | 40 |
19,501 | @ Override public boolean hasField ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return true ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return true ; return false ; } | Returns true if the specified field is either a grouping field or created by an aggregation function . | 74 | 18 |
19,502 | void flushAll ( ) { for ( Buffer buff : bufferPool ) { try { buff . getExternalLock ( ) . lock ( ) ; buff . flush ( ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } } | Flushes all dirty buffers . | 53 | 6 |
19,503 | Buffer pin ( BlockId blk ) { // Only the txs acquiring the same block will be blocked synchronized ( prepareAnchor ( blk ) ) { // Find existing buffer Buffer buff = findExistingBuffer ( blk ) ; // If there is no such buffer if ( buff == null ) { // Choose Unpinned Buffer int lastReplacedBuff = this . lastReplacedBuff ; int currBlk = ( lastReplacedBuff + 1 ) % bufferPool . length ; while ( currBlk != lastReplacedBuff ) { buff = bufferPool [ currBlk ] ; // Get the lock of buffer if it is free if ( buff . getExternalLock ( ) . tryLock ( ) ) { try { // Check if there is no one use it if ( ! buff . isPinned ( ) ) { this . lastReplacedBuff = currBlk ; // Swap BlockId oldBlk = buff . block ( ) ; if ( oldBlk != null ) blockMap . remove ( oldBlk ) ; buff . assignToBlock ( blk ) ; blockMap . put ( blk , buff ) ; if ( ! buff . isPinned ( ) ) numAvailable . decrementAndGet ( ) ; // Pin this buffer buff . pin ( ) ; return buff ; } } finally { // Release the lock of buffer buff . getExternalLock ( ) . unlock ( ) ; } } currBlk = ( currBlk + 1 ) % bufferPool . length ; } return null ; // If it exists } else { // Get the lock of buffer buff . getExternalLock ( ) . lock ( ) ; try { // Check its block id before pinning since it might be swapped if ( buff . block ( ) . equals ( blk ) ) { if ( ! buff . isPinned ( ) ) numAvailable . decrementAndGet ( ) ; buff . pin ( ) ; return buff ; } return pin ( blk ) ; } finally { // Release the lock of buffer buff . getExternalLock ( ) . unlock ( ) ; } } } } | Pins a buffer to the specified block . If there is already a buffer assigned to that block then that buffer is used ; otherwise an unpinned buffer from the pool is chosen . Returns a null value if there are no available buffers . | 439 | 48 |
19,504 | void unpin ( Buffer ... buffs ) { for ( Buffer buff : buffs ) { try { // Get the lock of buffer buff . getExternalLock ( ) . lock ( ) ; buff . unpin ( ) ; if ( ! buff . isPinned ( ) ) numAvailable . incrementAndGet ( ) ; } finally { // Release the lock of buffer buff . getExternalLock ( ) . unlock ( ) ; } } } | Unpins the specified buffers . | 88 | 6 |
19,505 | public static void initializeSystem ( Transaction tx ) { tx . recoveryMgr ( ) . recoverSystem ( tx ) ; tx . bufferMgr ( ) . flushAll ( ) ; VanillaDb . logMgr ( ) . removeAndCreateNewLog ( ) ; // Add a start record for this transaction new StartRecord ( tx . getTransactionNumber ( ) ) . writeToLog ( ) ; } | Goes through the log rolling back all uncompleted transactions . Flushes all modified blocks . Finally writes a quiescent checkpoint record to the log and flush it . This method should be called only during system startup before user transactions begin . | 82 | 47 |
19,506 | @ Override public void onTxCommit ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { LogSeqNum lsn = new CommitRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } } | Writes a commit record to the log and then flushes the log record to disk . | 68 | 18 |
19,507 | @ Override public void onTxRollback ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { rollback ( tx ) ; LogSeqNum lsn = new RollbackRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } } | Does the roll back process writes a rollback record to the log and flushes the log record to disk . | 75 | 22 |
19,508 | public LogSeqNum logSetVal ( Buffer buff , int offset , Constant newVal ) { if ( enableLogging ) { BlockId blk = buff . block ( ) ; if ( isTempBlock ( blk ) ) return null ; return new SetValueRecord ( txNum , blk , offset , buff . getVal ( offset , newVal . getType ( ) ) , newVal ) . writeToLog ( ) ; } else return null ; } | Writes a set value record to the log . | 97 | 10 |
19,509 | public LogSeqNum logLogicalAbort ( long txNum , LogSeqNum undoNextLSN ) { if ( enableLogging ) { return new LogicalAbortRecord ( txNum , undoNextLSN ) . writeToLog ( ) ; } else return null ; } | Writes a logical abort record into the log . | 61 | 10 |
19,510 | @ Override public void delete ( SearchKey key , RecordId dataRecordId , boolean doLogicalLogging ) { if ( tx . isReadOnly ( ) ) throw new UnsupportedOperationException ( ) ; search ( new SearchRange ( key ) , SearchPurpose . DELETE ) ; // log the logical operation starts if ( doLogicalLogging ) tx . recoveryMgr ( ) . logLogicalStart ( ) ; leaf . delete ( dataRecordId ) ; // log the logical operation ends if ( doLogicalLogging ) tx . recoveryMgr ( ) . logIndexDeletionEnd ( ii . indexName ( ) , key , dataRecordId . block ( ) . number ( ) , dataRecordId . id ( ) ) ; } | Deletes the specified index record . The method first traverses the directory to find the leaf page containing that record ; then it deletes the record from the page . F | 160 | 34 |
19,511 | @ Override public void close ( ) { if ( leaf != null ) { leaf . close ( ) ; leaf = null ; } dirsMayBeUpdated = null ; } | Closes the index by closing its open leaf page if necessary . | 36 | 13 |
19,512 | public synchronized TableStatInfo getTableStatInfo ( TableInfo ti , Transaction tx ) { if ( isRefreshStatOn ) { Integer c = updateCounts . get ( ti . tableName ( ) ) ; if ( c != null && c > REFRESH_THRESHOLD ) VanillaDb . taskMgr ( ) . runTask ( new StatisticsRefreshTask ( tx , ti . tableName ( ) ) ) ; } TableStatInfo tsi = tableStats . get ( ti . tableName ( ) ) ; if ( tsi == null ) { tsi = calcTableStats ( ti , tx ) ; tableStats . put ( ti . tableName ( ) , tsi ) ; } return tsi ; } | Returns the statistical information about the specified table . | 152 | 9 |
19,513 | @ Override public boolean hasNext ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } return currentRec > 0 || blk . number ( ) > 0 ; } | Determines if the current log record is the earliest record in the log file . | 48 | 17 |
19,514 | @ Override public BasicLogRecord next ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } if ( currentRec == 0 ) moveToNextBlock ( ) ; currentRec = ( Integer ) pg . getVal ( currentRec , INTEGER ) . asJavaVal ( ) ; return new BasicLogRecord ( pg , new LogSeqNum ( blk . number ( ) , currentRec + pointerSize * 2 ) ) ; } | Moves to the next log record in reverse order . If the current log record is the earliest in its block then the method moves to the next oldest block and returns the log record from there . | 104 | 39 |
19,515 | private void moveToNextBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) - 1 ) ; pg . read ( blk ) ; currentRec = ( Integer ) pg . getVal ( LogMgr . LAST_POS , INTEGER ) . asJavaVal ( ) ; } | Moves to the next log block in reverse order and positions it after the last record in that block . | 73 | 21 |
19,516 | private void moveToPrevBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) + 1 ) ; pg . read ( blk ) ; currentRec = 0 + pointerSize ; } | Moves to the previous log block in reverse order and positions it after the last record in that block . | 51 | 21 |
19,517 | @ Override public Constant evaluate ( Record rec ) { return op . evaluate ( lhs , rhs , rec ) ; } | Evaluates the arithmetic expression by computing on the values from the record . | 26 | 15 |
19,518 | @ Override public boolean isApplicableTo ( Schema sch ) { return lhs . isApplicableTo ( sch ) && rhs . isApplicableTo ( sch ) ; } | Returns true if both expressions are in the specified schema . | 39 | 11 |
19,519 | public static void formatFileHeader ( String fileName , Transaction tx ) { tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; // header should be the first block of the given file if ( VanillaDb . fileMgr ( ) . size ( fileName ) == 0 ) { FileHeaderFormatter fhf = new FileHeaderFormatter ( ) ; Buffer buff = tx . bufferMgr ( ) . pinNew ( fileName , fhf ) ; tx . bufferMgr ( ) . unpin ( buff ) ; } } | Format the header of specified file . | 116 | 7 |
19,520 | public boolean next ( ) { if ( currentBlkNum == 0 && ! moveTo ( 1 ) ) return false ; while ( true ) { if ( rp . next ( ) ) return true ; if ( ! moveTo ( currentBlkNum + 1 ) ) return false ; } } | Moves to the next record . Returns false if there is no next record . | 61 | 16 |
19,521 | public void setVal ( String fldName , Constant val ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; Type fldType = ti . schema ( ) . type ( fldName ) ; Constant v = val . castTo ( fldType ) ; if ( Page . size ( v ) > Page . maxSize ( fldType ) ) throw new SchemaIncompatibleException ( ) ; rp . setVal ( fldName , v ) ; } | Sets a value of the specified field in the current record . The type of the value must be equal to that of the specified field . | 114 | 28 |
19,522 | public void insert ( ) { // Block read-only transaction if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; // Insertion may change the properties of this file, // so that we need to lock the file. if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; // Modify the free chain which is start from a pointer in // the header of the file. if ( fhp == null ) fhp = openHeaderForModification ( ) ; // Log that this logical operation starts tx . recoveryMgr ( ) . logLogicalStart ( ) ; if ( fhp . hasDeletedSlots ( ) ) { // Insert into a deleted slot moveToRecordId ( fhp . getLastDeletedSlot ( ) ) ; RecordId lds = rp . insertIntoDeletedSlot ( ) ; fhp . setLastDeletedSlot ( lds ) ; } else { // Insert into a empty slot if ( ! fhp . hasDataRecords ( ) ) { // no record inserted before // Create the first data block appendBlock ( ) ; moveTo ( 1 ) ; rp . insertIntoNextEmptySlot ( ) ; } else { // Find the tail page RecordId tailSlot = fhp . getTailSolt ( ) ; moveToRecordId ( tailSlot ) ; while ( ! rp . insertIntoNextEmptySlot ( ) ) { if ( atLastBlock ( ) ) appendBlock ( ) ; moveTo ( currentBlkNum + 1 ) ; } } fhp . setTailSolt ( currentRecordId ( ) ) ; } // Log that this logical operation ends RecordId insertedRid = currentRecordId ( ) ; tx . recoveryMgr ( ) . logRecordFileInsertionEnd ( ti . tableName ( ) , insertedRid . block ( ) . number ( ) , insertedRid . id ( ) ) ; // Close the header (release the header lock) closeHeader ( ) ; } | Inserts a new blank record somewhere in the file beginning at the current record . If the new record does not fit into an existing block then a new block is appended to the file . | 438 | 38 |
19,523 | public void insert ( RecordId rid ) { // Block read-only transaction if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; // Insertion may change the properties of this file, // so that we need to lock the file. if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; // Open the header if ( fhp == null ) fhp = openHeaderForModification ( ) ; // Log that this logical operation starts tx . recoveryMgr ( ) . logLogicalStart ( ) ; // Mark the specified slot as in used moveToRecordId ( rid ) ; if ( ! rp . insertIntoTheCurrentSlot ( ) ) throw new RuntimeException ( "the specified slot: " + rid + " is in used" ) ; // Traverse the free chain to find the specified slot RecordId lastSlot = null ; RecordId currentSlot = fhp . getLastDeletedSlot ( ) ; while ( ! currentSlot . equals ( rid ) && currentSlot . block ( ) . number ( ) != FileHeaderPage . NO_SLOT_BLOCKID ) { moveToRecordId ( currentSlot ) ; lastSlot = currentSlot ; currentSlot = rp . getNextDeletedSlotId ( ) ; } // Remove the specified slot from the chain // If it is the first slot if ( lastSlot == null ) { moveToRecordId ( currentSlot ) ; fhp . setLastDeletedSlot ( rp . getNextDeletedSlotId ( ) ) ; // If it is in the middle } else if ( currentSlot . block ( ) . number ( ) != FileHeaderPage . NO_SLOT_BLOCKID ) { moveToRecordId ( currentSlot ) ; RecordId nextSlot = rp . getNextDeletedSlotId ( ) ; moveToRecordId ( lastSlot ) ; rp . setNextDeletedSlotId ( nextSlot ) ; } // Log that this logical operation ends tx . recoveryMgr ( ) . logRecordFileInsertionEnd ( ti . tableName ( ) , rid . block ( ) . number ( ) , rid . id ( ) ) ; // Close the header (release the header lock) closeHeader ( ) ; } | Inserts a record to a specified physical address . | 486 | 10 |
19,524 | public void moveToRecordId ( RecordId rid ) { moveTo ( rid . block ( ) . number ( ) ) ; rp . moveToId ( rid . id ( ) ) ; } | Positions the current record as indicated by the specified record ID . | 41 | 13 |
19,525 | public RecordId currentRecordId ( ) { int id = rp . currentId ( ) ; return new RecordId ( new BlockId ( fileName , currentBlkNum ) , id ) ; } | Returns the record ID of the current record . | 42 | 9 |
19,526 | public Operator operator ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) ) return op ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) ) return op . complement ( ) ; return null ; } | Determines if this term is of the form F< ; OP> ; E where F is the specified field < ; OP> ; is an operator and E is an expression . If so the method returns < ; OP> ; . If not the method returns null . | 78 | 61 |
19,527 | public Constant oppositeConstant ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isConstant ( ) ) return rhs . asConstant ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isConstant ( ) ) return lhs . asConstant ( ) ; return null ; } | Determines if this term is of the form F< ; OP> ; C where F is the specified field < ; OP> ; is an operator and C is some constant . If so the method returns C . If not the method returns null . | 108 | 55 |
19,528 | public String oppositeField ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isFieldName ( ) ) return rhs . asFieldName ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isFieldName ( ) ) return lhs . asFieldName ( ) ; return null ; } | Determines if this term is of the form F1< ; OP> ; F2 where F1 is the specified field < ; OP> ; is an operator and F2 is another field . If so the method returns F2 . If not the method returns null . | 107 | 60 |
19,529 | public synchronized Hosts putAllInRandomOrder ( String domain , String [ ] ips ) { Random random = new Random ( ) ; int index = ( int ) ( random . nextLong ( ) % ips . length ) ; if ( index < 0 ) { index += ips . length ; } LinkedList < String > ipList = new LinkedList < String > ( ) ; for ( int i = 0 ; i < ips . length ; i ++ ) { ipList . add ( ips [ ( i + index ) % ips . length ] ) ; } hosts . put ( domain , ipList ) ; return this ; } | avoid many server visit first ip in same time . s | 136 | 11 |
19,530 | public static String [ ] getByInternalAPI ( ) { try { Class < ? > resolverConfiguration = Class . forName ( "sun.net.dns.ResolverConfiguration" ) ; Method open = resolverConfiguration . getMethod ( "open" ) ; Method getNameservers = resolverConfiguration . getMethod ( "nameservers" ) ; Object instance = open . invoke ( null ) ; List nameservers = ( List ) getNameservers . invoke ( instance ) ; if ( nameservers == null || nameservers . size ( ) == 0 ) { return null ; } String [ ] ret = new String [ nameservers . size ( ) ] ; int i = 0 ; for ( Object dns : nameservers ) { ret [ i ++ ] = ( String ) dns ; } return ret ; } catch ( Exception e ) { // we might trigger some problems this way e . printStackTrace ( ) ; } return null ; } | has 300s latency when system resolv change | 205 | 10 |
19,531 | public static IResolver defaultResolver ( ) { return new IResolver ( ) { @ Override public Record [ ] resolve ( Domain domain ) throws IOException { String [ ] addresses = defaultServer ( ) ; if ( addresses == null ) { throw new IOException ( "no dns server" ) ; } IResolver resolver = new Resolver ( InetAddress . getByName ( addresses [ 0 ] ) ) ; return resolver . resolve ( domain ) ; } } ; } | system ip would change | 104 | 4 |
19,532 | void writeAssocBean ( ) throws IOException { writingAssocBean = true ; origDestPackage = destPackage ; destPackage = destPackage + ".assoc" ; origShortName = shortName ; shortName = "Assoc" + shortName ; prepareAssocBeanImports ( ) ; writer = new Append ( createFileWriter ( ) ) ; writePackage ( ) ; writeImports ( ) ; writeClass ( ) ; writeFields ( ) ; writeConstructors ( ) ; writeClassEnd ( ) ; writer . close ( ) ; } | Write the type query assoc bean . | 120 | 8 |
19,533 | private void prepareAssocBeanImports ( ) { importTypes . remove ( DB ) ; importTypes . remove ( TQROOTBEAN ) ; importTypes . remove ( DATABASE ) ; importTypes . add ( TQASSOCBEAN ) ; if ( isEntity ( ) ) { importTypes . add ( TQPROPERTY ) ; importTypes . add ( origDestPackage + ".Q" + origShortName ) ; } // remove imports for the same package Iterator < String > importsIterator = importTypes . iterator ( ) ; String checkImportStart = destPackage + ".QAssoc" ; while ( importsIterator . hasNext ( ) ) { String importType = importsIterator . next ( ) ; if ( importType . startsWith ( checkImportStart ) ) { importsIterator . remove ( ) ; } } } | Prepare the imports for writing assoc bean . | 178 | 10 |
19,534 | private void writeRootBeanConstructor ( ) throws IOException { writer . eol ( ) ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct with a given Database." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " public Q%s(Database server) {" , shortName ) . eol ( ) ; writer . append ( " super(%s.class, server);" , shortName ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; writer . eol ( ) ; String name = ( dbName == null ) ? "default" : dbName ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct using the %s Database." , name ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " public Q%s() {" , shortName ) . eol ( ) ; if ( dbName == null ) { writer . append ( " super(%s.class);" , shortName ) . eol ( ) ; } else { writer . append ( " super(%s.class, DB.byName(\"%s\"));" , shortName , dbName ) . eol ( ) ; } writer . append ( " }" ) . eol ( ) ; writer . eol ( ) ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct for Alias." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " private Q%s(boolean dummy) {" , shortName ) . eol ( ) ; writer . append ( " super(dummy);" ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; } | Write the constructors for root type query bean . | 423 | 10 |
19,535 | private void writeAssocBeanConstructor ( ) { writer . append ( " public Q%s(String name, R root) {" , shortName ) . eol ( ) ; writer . append ( " super(name, root);" ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; } | Write constructor for assoc type query bean . | 73 | 9 |
19,536 | private void writeFields ( ) throws IOException { for ( PropertyMeta property : properties ) { property . writeFieldDefn ( writer , shortName , writingAssocBean ) ; writer . eol ( ) ; } writer . eol ( ) ; } | Write all the fields . | 55 | 5 |
19,537 | private void writeClass ( ) { if ( writingAssocBean ) { writer . append ( "/**" ) . eol ( ) ; writer . append ( " * Association query bean for %s." , shortName ) . eol ( ) ; writer . append ( " * " ) . eol ( ) ; writer . append ( " * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; if ( processingContext . isGeneratedAvailable ( ) ) { writer . append ( AT_GENERATED ) . eol ( ) ; } writer . append ( AT_TYPEQUERYBEAN ) . eol ( ) ; writer . append ( "public class Q%s<R> extends TQAssocBean<%s,R> {" , shortName , origShortName ) . eol ( ) ; } else { writer . append ( "/**" ) . eol ( ) ; writer . append ( " * Query bean for %s." , shortName ) . eol ( ) ; writer . append ( " * " ) . eol ( ) ; writer . append ( " * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; if ( processingContext . isGeneratedAvailable ( ) ) { writer . append ( AT_GENERATED ) . eol ( ) ; } writer . append ( AT_TYPEQUERYBEAN ) . eol ( ) ; writer . append ( "public class Q%s extends TQRootBean<%1$s,Q%1$s> {" , shortName ) . eol ( ) ; } writer . eol ( ) ; } | Write the class definition . | 393 | 5 |
19,538 | private void writeImports ( ) { for ( String importType : importTypes ) { writer . append ( "import %s;" , importType ) . eol ( ) ; } writer . eol ( ) ; } | Write all the imports . | 46 | 5 |
19,539 | static String [ ] split ( String className ) { String [ ] result = new String [ 2 ] ; int startPos = className . lastIndexOf ( ' ' ) ; if ( startPos == - 1 ) { result [ 1 ] = className ; return result ; } result [ 0 ] = className . substring ( 0 , startPos ) ; result [ 1 ] = className . substring ( startPos + 1 ) ; return result ; } | Split into package and class name . | 96 | 7 |
19,540 | static String shortName ( String className ) { int startPos = className . lastIndexOf ( ' ' ) ; if ( startPos == - 1 ) { return className ; } return className . substring ( startPos + 1 ) ; } | Trim off package to return the simple class name . | 53 | 11 |
19,541 | Append append ( String format , Object ... args ) { return append ( String . format ( format , args ) ) ; } | Append content with formatted arguments . | 26 | 7 |
19,542 | < A extends Annotation > A findAnnotation ( TypeElement element , Class < A > anno ) { final A annotation = element . getAnnotation ( anno ) ; if ( annotation != null ) { return annotation ; } final TypeMirror typeMirror = element . getSuperclass ( ) ; if ( typeMirror . getKind ( ) == TypeKind . NONE ) { return null ; } final TypeElement element1 = ( TypeElement ) typeUtils . asElement ( typeMirror ) ; return findAnnotation ( element1 , anno ) ; } | Find the annotation searching the inheritance hierarchy . | 121 | 8 |
19,543 | private static boolean dbJsonField ( Element field ) { return ( field . getAnnotation ( DbJson . class ) != null || field . getAnnotation ( DbJsonB . class ) != null ) ; } | Return true if it is a DbJson field . | 49 | 12 |
19,544 | private PropertyType createPropertyTypeAssoc ( String fullName ) { String [ ] split = Split . split ( fullName ) ; String propertyName = "QAssoc" + split [ 1 ] ; String packageName = packageAppend ( split [ 0 ] , "query.assoc" ) ; return new PropertyTypeAssoc ( propertyName , packageName ) ; } | Create the QAssoc PropertyType . | 78 | 8 |
19,545 | private String packageAppend ( String origPackage , String suffix ) { if ( origPackage == null ) { return suffix ; } else { return origPackage + "." + suffix ; } } | Prepend the package to the suffix taking null into account . | 39 | 12 |
19,546 | JavaFileObject createWriter ( String factoryClassName , Element originatingElement ) throws IOException { return filer . createSourceFile ( factoryClassName , originatingElement ) ; } | Create a file writer for the given class name . | 35 | 10 |
19,547 | public static String printNode ( Node node , boolean prettyprint ) { StringWriter strw = new StringWriter ( ) ; new DOMWriter ( strw ) . setPrettyprint ( prettyprint ) . print ( node ) ; return strw . toString ( ) ; } | Print a node with explicit prettyprinting . The defaults for all other DOMWriter properties apply . | 56 | 19 |
19,548 | public static String resolve ( String normalized ) { StringBuilder builder = new StringBuilder ( ) ; int end = normalized . length ( ) ; int pos = normalized . indexOf ( ' ' ) ; int last = 0 ; // No references if ( pos == - 1 ) return normalized ; while ( pos != - 1 ) { String sub = normalized . subSequence ( last , pos ) . toString ( ) ; builder . append ( sub ) ; int peek = pos + 1 ; if ( peek == end ) throw MESSAGES . entityResolutionInvalidEntityReference ( normalized ) ; if ( normalized . charAt ( peek ) == ' ' ) pos = resolveCharRef ( normalized , pos , builder ) ; else pos = resolveEntityRef ( normalized , pos , builder ) ; last = pos ; pos = normalized . indexOf ( ' ' , pos ) ; } if ( last < end ) { String sub = normalized . subSequence ( last , end ) . toString ( ) ; builder . append ( sub ) ; } return builder . toString ( ) ; } | Transforms an XML normalized string by resolving all predefined character and entity references | 222 | 15 |
19,549 | private static void invokeMethod ( final Object instance , final Method method , final Object [ ] args ) { final boolean accessability = method . isAccessible ( ) ; try { method . setAccessible ( true ) ; method . invoke ( instance , args ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { method . setAccessible ( accessability ) ; } } | Invokes method on object with specified arguments . | 86 | 9 |
19,550 | private static void setField ( final Object instance , final Field field , final Object value ) { final boolean accessability = field . isAccessible ( ) ; try { field . setAccessible ( true ) ; field . set ( instance , value ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { field . setAccessible ( accessability ) ; } } | Sets field on object with specified value . | 84 | 9 |
19,551 | @ Override public void onEndpointInstantiated ( final Endpoint endpoint , final Invocation invocation ) { final Object _targetBean = this . getTargetBean ( invocation ) ; // TODO: refactor injection to AS IL final Reference reference = endpoint . getInstanceProvider ( ) . getInstance ( _targetBean . getClass ( ) . getName ( ) ) ; final Object targetBean = reference . getValue ( ) ; InjectionHelper . injectWebServiceContext ( targetBean , ThreadLocalAwareWebServiceContext . getInstance ( ) ) ; if ( ! reference . isInitialized ( ) ) { InjectionHelper . callPostConstructMethod ( targetBean ) ; reference . setInitialized ( ) ; } endpoint . addAttachment ( PreDestroyHolder . class , new PreDestroyHolder ( targetBean ) ) ; } | Injects resources on target bean and calls post construct method . Finally it registers target bean for predestroy phase . | 179 | 24 |
19,552 | private Object getTargetBean ( final Invocation invocation ) { final InvocationContext invocationContext = invocation . getInvocationContext ( ) ; return invocationContext . getTargetBean ( ) ; } | Returns endpoint instance associated with current invocation . | 41 | 8 |
19,553 | public static < A > A getRequiredAttachment ( final Deployment dep , final Class < A > key ) { final A value = dep . getAttachment ( key ) ; if ( value == null ) { throw Messages . MESSAGES . cannotFindAttachmentInDeployment ( key , dep . getSimpleName ( ) ) ; } return value ; } | Returns required attachment value from webservice deployment . | 76 | 10 |
19,554 | public static < A > A getOptionalAttachment ( final Deployment dep , final Class < A > key ) { return dep . getAttachment ( key ) ; } | Returns optional attachment value from webservice deployment or null if not bound . | 35 | 15 |
19,555 | protected void createConstructorDelegates ( ConstructorBodyCreator creator ) { ClassMetadataSource data = reflectionMetadataSource . getClassMetadata ( getSuperClass ( ) ) ; for ( Constructor < ? > constructor : data . getConstructors ( ) ) { if ( ! Modifier . isPrivate ( constructor . getModifiers ( ) ) ) { creator . overrideConstructor ( classFile . addMethod ( AccessFlag . PUBLIC , "<init>" , "V" , DescriptorUtils . parameterDescriptors ( constructor . getParameterTypes ( ) ) ) , constructor ) ; } } } | Adds constructors that delegate the the superclass constructor for all non - private constructors present on the superclass | 128 | 22 |
19,556 | public static void assertNoPrimitiveParameters ( final Method method , Class < ? extends Annotation > annotation ) { for ( Class < ? > type : method . getParameterTypes ( ) ) { if ( type . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . methodCannotDeclarePrimitiveParameters ( method ) : MESSAGES . methodCannotDeclarePrimitiveParameters2 ( method , annotation ) ; } } } | Asserts method don t declare primitive parameters . | 96 | 10 |
19,557 | public static void assertNotPrimitiveType ( final Field field , Class < ? extends Annotation > annotation ) { if ( field . getType ( ) . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldCannotBeOfPrimitiveOrVoidType2 ( field , annotation ) ; } } | Asserts field is not of primitive type . | 89 | 10 |
19,558 | public static void assertNoParameters ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 0 ) { throw annotation == null ? MESSAGES . methodHasToHaveNoParameters ( method ) : MESSAGES . methodHasToHaveNoParameters2 ( method , annotation ) ; } } | Asserts method have no parameters . | 76 | 8 |
19,559 | public static void assertVoidReturnType ( final Method method , Class < ? extends Annotation > annotation ) { if ( ( ! method . getReturnType ( ) . equals ( Void . class ) ) && ( ! method . getReturnType ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . methodHasToReturnVoid ( method ) : MESSAGES . methodHasToReturnVoid2 ( method , annotation ) ; } } | Asserts method return void . | 102 | 7 |
19,560 | public static void assertNotVoidType ( final Field field , Class < ? extends Annotation > annotation ) { if ( ( field . getClass ( ) . equals ( Void . class ) ) && ( field . getClass ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldCannotBeOfPrimitiveOrVoidType2 ( field , annotation ) ; } } | Asserts field isn t of void type . | 108 | 10 |
19,561 | public static void assertNoCheckedExceptionsAreThrown ( final Method method , Class < ? extends Annotation > annotation ) { Class < ? > [ ] declaredExceptions = method . getExceptionTypes ( ) ; for ( int i = 0 ; i < declaredExceptions . length ; i ++ ) { Class < ? > exception = declaredExceptions [ i ] ; if ( ! exception . isAssignableFrom ( RuntimeException . class ) ) { throw annotation == null ? MESSAGES . methodCannotThrowCheckedException ( method ) : MESSAGES . methodCannotThrowCheckedException2 ( method , annotation ) ; } } } | Asserts method don t throw checked exceptions . | 138 | 10 |
19,562 | public static void assertNotStatic ( final Method method , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . methodCannotBeStatic ( method ) : MESSAGES . methodCannotBeStatic2 ( method , annotation ) ; } } | Asserts method is not static . | 77 | 8 |
19,563 | public static void assertNotStatic ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } } | Asserts field is not static . | 81 | 8 |
19,564 | public static void assertNotFinal ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isFinal ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } } | Asserts field is not final . | 81 | 8 |
19,565 | public static void assertOneParameter ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 1 ) { throw annotation == null ? MESSAGES . methodHasToDeclareExactlyOneParameter ( method ) : MESSAGES . methodHasToDeclareExactlyOneParameter2 ( method , annotation ) ; } } | Asserts method have exactly one parameter . | 80 | 9 |
19,566 | public static void assertValidSetterName ( final Method method , Class < ? extends Annotation > annotation ) { final String methodName = method . getName ( ) ; final boolean correctMethodNameLength = methodName . length ( ) > 3 ; final boolean isSetterMethodName = methodName . startsWith ( "set" ) ; final boolean isUpperCasedPropertyName = correctMethodNameLength ? Character . isUpperCase ( methodName . charAt ( 3 ) ) : false ; if ( ! correctMethodNameLength || ! isSetterMethodName || ! isUpperCasedPropertyName ) { throw annotation == null ? MESSAGES . methodDoesNotRespectJavaBeanSetterMethodName ( method ) : MESSAGES . methodDoesNotRespectJavaBeanSetterMethodName2 ( method , annotation ) ; } } | Asserts valid Java Beans setter method name . | 181 | 11 |
19,567 | public static void assertOnlyOneMethod ( final Collection < Method > methods , Class < ? extends Annotation > annotation ) { if ( methods . size ( ) > 1 ) { throw annotation == null ? MESSAGES . onlyOneMethodCanExist ( ) : MESSAGES . onlyOneMethodCanExist2 ( annotation ) ; } } | Asserts only one method is annotated with annotation . | 73 | 12 |
19,568 | public final void invoke ( final Endpoint endpoint , final Invocation invocation ) throws Exception { try { // prepare for invocation this . init ( endpoint , invocation ) ; final Object targetBean = invocation . getInvocationContext ( ) . getTargetBean ( ) ; final Class < ? > implClass = targetBean . getClass ( ) ; final Method seiMethod = invocation . getJavaMethod ( ) ; final Method implMethod = this . getImplMethod ( implClass , seiMethod ) ; final Object [ ] args = invocation . getArgs ( ) ; // notify subclasses this . onBeforeInvocation ( invocation ) ; // invoke implementation method final Object retObj = implMethod . invoke ( targetBean , args ) ; // set invocation result invocation . setReturnValue ( retObj ) ; } catch ( Exception e ) { Loggers . ROOT_LOGGER . methodInvocationFailed ( e ) ; // propagate exception this . handleInvocationException ( e ) ; } finally { // notify subclasses this . onAfterInvocation ( invocation ) ; } } | Invokes method on endpoint implementation . | 224 | 7 |
19,569 | @ Override public < T > T getSPI ( Class < T > spiType , ClassLoader loader ) { T returnType = null ; // SPIs provided by framework, defaults can be overridden if ( DeploymentModelFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultDeploymentModelFactory . class , loader ) ; } else if ( EndpointMetricsFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultEndpointMetricsFactory . class , loader ) ; } else if ( LifecycleHandlerFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultLifecycleHandlerFactory . class , loader ) ; } else if ( SecurityAdaptorFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultSecurityAdapterFactory . class , loader ) ; } else if ( JMSEndpointResolver . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultJMSEndpointResolver . class , loader ) ; } else { // SPI provided by either container or stack integration that has no default implementation returnType = ( T ) loadService ( spiType , null , loader ) ; } if ( returnType == null ) throw Messages . MESSAGES . failedToProvideSPI ( spiType ) ; return returnType ; } | Gets the specified SPI using the provided classloader | 315 | 10 |
19,570 | @ SuppressWarnings ( "unchecked" ) private < T > T loadService ( Class < T > spiType , Class < ? > defaultImpl , ClassLoader loader ) { final String defaultImplName = defaultImpl != null ? defaultImpl . getName ( ) : null ; return ( T ) ServiceLoader . loadService ( spiType . getName ( ) , defaultImplName , loader ) ; } | Load SPI implementation through ServiceLoader | 88 | 6 |
19,571 | private boolean isRecording ( Endpoint endpoint ) { List < RecordProcessor > processors = endpoint . getRecordProcessors ( ) ; if ( processors == null || processors . isEmpty ( ) ) { return false ; } for ( RecordProcessor processor : processors ) { if ( processor . isRecording ( ) ) { return true ; } } return false ; } | Returns true if there s at least a record processor in recording mode | 76 | 13 |
19,572 | public static void rethrow ( final String message , final Exception reason ) { if ( reason == null ) { throw new IllegalArgumentException ( ) ; } Loggers . ROOT_LOGGER . error ( message == null ? reason . getMessage ( ) : message , reason ) ; throw new InjectionException ( message , reason ) ; } | Rethrows Injection exception that will wrap passed reason . | 71 | 12 |
19,573 | public EndpointConfig resolveEndpointConfig ( ) { final String endpointClassName = getEndpointClassName ( ) ; // 1) default values //String configName = org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG; String configName = endpointClassName ; String configFile = EndpointConfig . DEFAULT_ENDPOINT_CONFIG_FILE ; boolean specifiedConfig = false ; // 2) annotation contribution if ( isEndpointClassAnnotated ( org . jboss . ws . api . annotation . EndpointConfig . class ) ) { final String cfgName = getEndpointConfigNameFromAnnotation ( ) ; if ( cfgName != null && ! cfgName . isEmpty ( ) ) { configName = cfgName ; } final String cfgFile = getEndpointConfigFileFromAnnotation ( ) ; if ( cfgFile != null && ! cfgFile . isEmpty ( ) ) { configFile = cfgFile ; } specifiedConfig = true ; } // 3) descriptor overrides (jboss-webservices.xml or web.xml) final String epCfgNameOverride = getEndpointConfigNameOverride ( ) ; if ( epCfgNameOverride != null && ! epCfgNameOverride . isEmpty ( ) ) { configName = epCfgNameOverride ; specifiedConfig = true ; } final String epCfgFileOverride = getEndpointConfigFileOverride ( ) ; if ( epCfgFileOverride != null && ! epCfgFileOverride . isEmpty ( ) ) { configFile = epCfgFileOverride ; } // 4) setup of configuration if ( configFile != EndpointConfig . DEFAULT_ENDPOINT_CONFIG_FILE ) { //look for provided endpoint config file try { ConfigRoot configRoot = ConfigMetaDataParser . parse ( getConfigFile ( configFile ) ) ; EndpointConfig config = configRoot . getEndpointConfigByName ( configName ) ; if ( config == null && ! specifiedConfig ) { config = configRoot . getEndpointConfigByName ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } if ( config != null ) { return config ; } } catch ( IOException e ) { throw Messages . MESSAGES . couldNotReadConfigFile ( configFile ) ; } } else { EndpointConfig config = null ; URL url = getDefaultConfigFile ( configFile ) ; if ( url != null ) { //the default file exists try { ConfigRoot configRoot = ConfigMetaDataParser . parse ( url ) ; config = configRoot . getEndpointConfigByName ( configName ) ; if ( config == null && ! specifiedConfig ) { config = configRoot . getEndpointConfigByName ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } } catch ( IOException e ) { throw Messages . MESSAGES . couldNotReadConfigFile ( configFile ) ; } } if ( config == null ) { //use endpoint configs from AS domain ServerConfig sc = getServerConfig ( ) ; config = sc . getEndpointConfig ( configName ) ; if ( config == null && ! specifiedConfig ) { config = sc . getEndpointConfig ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } if ( config == null && specifiedConfig ) { throw Messages . MESSAGES . couldNotFindEndpointConfigName ( configName ) ; } } if ( config != null ) { return config ; } } return null ; } | Returns the EndpointConfig resolved for the current endpoint | 770 | 10 |
19,574 | public Set < String > getAllHandlers ( EndpointConfig config ) { Set < String > set = new HashSet < String > ( ) ; if ( config != null ) { for ( UnifiedHandlerChainMetaData uhcmd : config . getPreHandlerChains ( ) ) { for ( UnifiedHandlerMetaData uhmd : uhcmd . getHandlers ( ) ) { set . add ( uhmd . getHandlerClass ( ) ) ; } } for ( UnifiedHandlerChainMetaData uhcmd : config . getPostHandlerChains ( ) ) { for ( UnifiedHandlerMetaData uhmd : uhcmd . getHandlers ( ) ) { set . add ( uhmd . getHandlerClass ( ) ) ; } } } return set ; } | Returns a set of full qualified class names of the handlers from the specified endpoint config | 155 | 16 |
19,575 | @ SuppressWarnings ( "unchecked" ) protected void publishWsdlImports ( URL parentURL , Definition parentDefinition , List < String > published , String expLocation ) throws Exception { @ SuppressWarnings ( "rawtypes" ) Iterator it = parentDefinition . getImports ( ) . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { for ( Import wsdlImport : ( List < Import > ) it . next ( ) ) { String locationURI = wsdlImport . getLocationURI ( ) ; // its an external import, don't publish locally if ( locationURI . startsWith ( "http://" ) == false && locationURI . startsWith ( "https://" ) == false ) { // infinity loops prevention if ( published . contains ( locationURI ) ) { continue ; } else { published . add ( locationURI ) ; } String baseURI = parentURL . toExternalForm ( ) ; URL targetURL = new URL ( baseURI . substring ( 0 , baseURI . lastIndexOf ( "/" ) + 1 ) + locationURI ) ; File targetFile = new File ( targetURL . getFile ( ) ) ; //JBWS-3488 createParentDir ( targetFile ) ; Definition subdef = wsdlImport . getDefinition ( ) ; WSDLFactory wsdlFactory = WSDLFactory . newInstance ( ) ; javax . wsdl . xml . WSDLWriter wsdlWriter = wsdlFactory . newWSDLWriter ( ) ; BufferedOutputStream bfos = new BufferedOutputStream ( new FileOutputStream ( targetFile ) ) ; OutputStreamWriter osw = new OutputStreamWriter ( bfos , "UTF-8" ) ; try { wsdlWriter . writeWSDL ( subdef , osw ) ; } finally { osw . close ( ) ; } DEPLOYMENT_LOGGER . wsdlImportPublishedTo ( targetURL ) ; // recursively publish imports publishWsdlImports ( targetURL , subdef , published , expLocation ) ; // Publish XMLSchema imports Element subdoc = DOMUtils . parse ( targetURL . openStream ( ) , getDocumentBuilder ( ) ) ; publishSchemaImports ( targetURL , subdoc , published , expLocation ) ; } } } } | Publish the wsdl imports for a given wsdl definition | 506 | 14 |
19,576 | protected void publishSchemaImports ( URL parentURL , Element element , List < String > published , String expLocation ) throws Exception { Element childElement = getFirstChildElement ( element ) ; while ( childElement != null ) { //first check on namespace only to avoid doing anything on any other wsdl/schema elements final String ns = childElement . getNamespaceURI ( ) ; if ( Constants . NS_SCHEMA_XSD . equals ( ns ) ) { final String ln = childElement . getLocalName ( ) ; if ( "import" . equals ( ln ) || "include" . equals ( ln ) ) { String schemaLocation = childElement . getAttribute ( "schemaLocation" ) ; if ( schemaLocation . length ( ) > 0 && schemaLocation . startsWith ( "http://" ) == false && schemaLocation . startsWith ( "https://" ) == false ) { // infinity loops prevention if ( ! published . contains ( schemaLocation ) ) { published . add ( schemaLocation ) ; String baseURI = parentURL . toExternalForm ( ) ; URL xsdURL = new URL ( baseURI . substring ( 0 , baseURI . lastIndexOf ( "/" ) + 1 ) + schemaLocation ) ; File targetFile = new File ( xsdURL . getFile ( ) ) ; //JBWS-3488 createParentDir ( targetFile ) ; String deploymentName = dep . getCanonicalName ( ) ; // get the resource path including the separator int index = baseURI . indexOf ( deploymentName ) + 1 ; String resourcePath = baseURI . substring ( index + deploymentName . length ( ) ) ; //check for sub-directories resourcePath = resourcePath . substring ( 0 , resourcePath . lastIndexOf ( "/" ) + 1 ) ; resourcePath = expLocation + resourcePath + schemaLocation ; while ( resourcePath . indexOf ( "//" ) != - 1 ) { resourcePath = resourcePath . replace ( "//" , "/" ) ; } URL resourceURL = dep . getResourceResolver ( ) . resolve ( resourcePath ) ; InputStream is = new ResourceURL ( resourceURL ) . openStream ( ) ; if ( is == null ) throw MESSAGES . cannotFindSchemaImportInDeployment ( resourcePath , deploymentName ) ; FileOutputStream fos = null ; try { fos = new FileOutputStream ( targetFile ) ; IOUtils . copyStream ( fos , is ) ; } finally { if ( fos != null ) fos . close ( ) ; } DEPLOYMENT_LOGGER . xmlSchemaImportPublishedTo ( xsdURL ) ; // recursively publish imports Element subdoc = DOMUtils . parse ( xsdURL . openStream ( ) , getDocumentBuilder ( ) ) ; publishSchemaImports ( xsdURL , subdoc , published , expLocation ) ; } } } else if ( "schema" . equals ( ln ) ) { //recurse, as xsd:schema might contain an import publishSchemaImports ( parentURL , childElement , published , expLocation ) ; } } else if ( Constants . NS_WSDL11 . equals ( ns ) && "types" . equals ( childElement . getLocalName ( ) ) ) { //recurse as wsdl:types might contain a schema publishSchemaImports ( parentURL , childElement , published , expLocation ) ; } childElement = getNextSiblingElement ( childElement ) ; } } | Publish the schema imports for a given wsdl definition | 757 | 12 |
19,577 | public void unpublishWsdlFiles ( ) throws IOException { String deploymentDir = ( dep . getParent ( ) != null ? dep . getParent ( ) . getSimpleName ( ) : dep . getSimpleName ( ) ) ; File serviceDir = new File ( serverConfig . getServerDataDir ( ) . getCanonicalPath ( ) + "/wsdl/" + deploymentDir ) ; deleteWsdlPublishDirectory ( serviceDir ) ; } | Delete the published wsdl | 98 | 6 |
19,578 | protected void deleteWsdlPublishDirectory ( File dir ) throws IOException { String [ ] files = dir . list ( ) ; for ( int i = 0 ; files != null && i < files . length ; i ++ ) { String fileName = files [ i ] ; File file = new File ( dir + "/" + fileName ) ; if ( file . isDirectory ( ) ) { deleteWsdlPublishDirectory ( file ) ; } else { if ( file . delete ( ) == false ) DEPLOYMENT_LOGGER . cannotDeletePublishedWsdlDoc ( file . toURI ( ) . toURL ( ) ) ; } } // delete the directory as well if ( dir . delete ( ) == false ) { DEPLOYMENT_LOGGER . cannotDeletePublishedWsdlDoc ( dir . toURI ( ) . toURL ( ) ) ; } } | Delete the published wsdl document traversing down the dir structure | 186 | 13 |
19,579 | protected Object readResolve ( ) throws ObjectStreamException { try { Class < ? > proxyClass = getProxyClass ( ) ; Object instance = proxyClass . newInstance ( ) ; ProxyFactory . setInvocationHandlerStatic ( instance , handler ) ; return instance ; } catch ( InstantiationException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } } | Resolve the serialized proxy to a real instance . | 109 | 11 |
19,580 | protected Class < ? > getProxyClass ( ) throws ClassNotFoundException { ClassLoader classLoader = getProxyClassLoader ( ) ; return Class . forName ( proxyClassName , false , classLoader ) ; } | Get the associated proxy class . | 45 | 6 |
19,581 | public static DocumentBuilder newDocumentBuilder ( final DocumentBuilderFactory factory ) { try { final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; return builder ; } catch ( Exception e ) { throw MESSAGES . unableToCreateInstanceOf ( e , DocumentBuilder . class . getName ( ) ) ; } } | Creates a new DocumentBuilder instance using the provided DocumentBuilderFactory | 67 | 13 |
19,582 | public static Element parse ( String xmlString ) throws IOException { try { return parse ( new ByteArrayInputStream ( xmlString . getBytes ( "UTF-8" ) ) ) ; } catch ( IOException e ) { ROOT_LOGGER . cannotParse ( xmlString ) ; throw e ; } } | Parse the given XML string and return the root Element This uses the document builder associated with the current thread . | 66 | 22 |
19,583 | public static Element parse ( InputStream xmlStream , DocumentBuilder builder ) throws IOException { try { Document doc ; synchronized ( builder ) //synchronize to prevent concurrent parsing on the same DocumentBuilder { doc = builder . parse ( xmlStream ) ; } return doc . getDocumentElement ( ) ; } catch ( SAXException se ) { throw new IOException ( se . toString ( ) ) ; } finally { xmlStream . close ( ) ; } } | Parse the given XML stream and return the root Element | 95 | 11 |
19,584 | public static Element parse ( InputStream xmlStream ) throws IOException { DocumentBuilder builder = getDocumentBuilder ( ) ; return parse ( xmlStream , builder ) ; } | Parse the given XML stream and return the root Element This uses the document builder associated with the current thread . | 34 | 22 |
19,585 | public static Element parse ( InputSource source ) throws IOException { try { Document doc ; DocumentBuilder builder = getDocumentBuilder ( ) ; synchronized ( builder ) //synchronize to prevent concurrent parsing on the same DocumentBuilder { doc = builder . parse ( source ) ; } return doc . getDocumentElement ( ) ; } catch ( SAXException se ) { throw new IOException ( se . toString ( ) ) ; } finally { InputStream is = source . getByteStream ( ) ; if ( is != null ) { is . close ( ) ; } Reader r = source . getCharacterStream ( ) ; if ( r != null ) { r . close ( ) ; } } } | Parse the given input source and return the root Element . This uses the document builder associated with the current thread . | 143 | 23 |
19,586 | public static Element createElement ( String localPart ) { Document doc = getOwnerDocument ( ) ; if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {}" + localPart ) ; return doc . createElement ( localPart ) ; } | Create an Element for a given name . This uses the document builder associated with the current thread . | 64 | 19 |
19,587 | public static Element createElement ( String localPart , String prefix , String uri ) { Document doc = getOwnerDocument ( ) ; if ( prefix == null || prefix . length ( ) == 0 ) { if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {" + uri + "}" + localPart ) ; return doc . createElementNS ( uri , localPart ) ; } else { if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {" + uri + "}" + prefix + ":" + localPart ) ; return doc . createElementNS ( uri , prefix + ":" + localPart ) ; } } | Create an Element for a given name prefix and uri . This uses the document builder associated with the current thread . | 161 | 23 |
19,588 | public static Element createElement ( QName qname ) { return createElement ( qname . getLocalPart ( ) , qname . getPrefix ( ) , qname . getNamespaceURI ( ) ) ; } | Create an Element for a given QName . This uses the document builder associated with the current thread . | 46 | 20 |
19,589 | public static Text createTextNode ( String value ) { Document doc = getOwnerDocument ( ) ; return doc . createTextNode ( value ) ; } | Create a org . w3c . dom . Text node . This uses the document builder associated with the current thread . | 31 | 24 |
19,590 | public static Document getOwnerDocument ( ) { Document doc = documentThreadLocal . get ( ) ; if ( doc == null ) { doc = getDocumentBuilder ( ) . newDocument ( ) ; documentThreadLocal . set ( doc ) ; } return doc ; } | Get the owner document that is associated with the current thread | 54 | 11 |
19,591 | public static Element sourceToElement ( Source source ) throws IOException { Element retElement = null ; if ( source instanceof StreamSource ) { StreamSource streamSource = ( StreamSource ) source ; InputStream ins = streamSource . getInputStream ( ) ; if ( ins != null ) { retElement = DOMUtils . parse ( ins ) ; } Reader reader = streamSource . getReader ( ) ; if ( reader != null ) { retElement = DOMUtils . parse ( new InputSource ( reader ) ) ; } } else if ( source instanceof DOMSource ) { DOMSource domSource = ( DOMSource ) source ; Node node = domSource . getNode ( ) ; if ( node instanceof Element ) { retElement = ( Element ) node ; } else if ( node instanceof Document ) { retElement = ( ( Document ) node ) . getDocumentElement ( ) ; } } else if ( source instanceof SAXSource ) { // The fact that JAXBSource derives from SAXSource is an implementation detail. // Thus in general applications are strongly discouraged from accessing methods defined on SAXSource. // The XMLReader object obtained by the getXMLReader method shall be used only for parsing the InputSource object returned by the getInputSource method. final boolean hasInputSource = ( ( SAXSource ) source ) . getInputSource ( ) != null ; final boolean hasXMLReader = ( ( SAXSource ) source ) . getXMLReader ( ) != null ; if ( hasInputSource || hasXMLReader ) { try { TransformerFactory tf = TransformerFactory . newInstance ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( 1024 ) ; Transformer transformer = tf . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; transformer . transform ( source , new StreamResult ( baos ) ) ; retElement = DOMUtils . parse ( new ByteArrayInputStream ( baos . toByteArray ( ) ) ) ; } catch ( TransformerException ex ) { throw new IOException ( ex ) ; } } } else { throw MESSAGES . sourceTypeNotImplemented ( source . getClass ( ) ) ; } return retElement ; } | Parse the contents of the provided source into an element . This uses the document builder associated with the current thread . | 499 | 23 |
19,592 | public static String node2String ( final Node node ) throws UnsupportedEncodingException { return node2String ( node , true , Constants . DEFAULT_XML_CHARSET ) ; } | Converts XML node in pretty mode using UTF - 8 encoding to string . | 42 | 15 |
19,593 | public static String node2String ( final Node node , boolean prettyPrint ) throws UnsupportedEncodingException { return node2String ( node , prettyPrint , Constants . DEFAULT_XML_CHARSET ) ; } | Converts XML node in specified pretty mode using UTF - 8 encoding to string . | 47 | 16 |
19,594 | public static String node2String ( final Node node , boolean prettyPrint , String encoding ) throws UnsupportedEncodingException { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; new DOMWriter ( new PrintWriter ( baos ) , encoding ) . setPrettyprint ( prettyPrint ) . print ( node ) ; return baos . toString ( encoding ) ; } | Converts XML node in specified pretty mode and encoding to string . | 80 | 13 |
19,595 | public void setContextProperties ( Map < String , String > contextProperties ) { if ( contextProperties != null ) { this . contextProperties = new HashMap < String , String > ( 4 ) ; this . contextProperties . putAll ( contextProperties ) ; } } | This is called once at AS boot time during deployment aspect parsing ; this provided map is copied . | 61 | 19 |
19,596 | public String [ ] getParameterTypes ( ) { final String [ ] parameterTypes = this . parameterTypes ; return parameterTypes == NO_STRINGS ? parameterTypes : parameterTypes . clone ( ) ; } | Get the parameter type names as strings . | 42 | 8 |
19,597 | public Method getPublicMethod ( final Class < ? > clazz ) throws NoSuchMethodException , ClassNotFoundException { return clazz . getMethod ( name , typesOf ( parameterTypes , clazz . getClassLoader ( ) ) ) ; } | Look up a public method matching this method identifier using reflection . | 52 | 12 |
19,598 | public static MethodIdentifier getIdentifier ( final Class < ? > returnType , final String name , final Class < ? > ... parameterTypes ) { return new MethodIdentifier ( returnType . getName ( ) , name , namesOf ( parameterTypes ) ) ; } | Construct a new instance using class objects for the parameter types . | 56 | 12 |
19,599 | public static MethodIdentifier getIdentifier ( final String returnType , final String name , final String ... parameterTypes ) { return new MethodIdentifier ( returnType , name , parameterTypes ) ; } | Construct a new instance using string names for the return and parameter types . | 41 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.