signature:
public class Preconditions { /** * Check that a given string value is not blank ( i . e not null , not empty and not blank ) .
 * It throws a { @ link NullPointerException } exception if value is null and throw an
 * { @ link java . lang . IllegalArgumentException } if value is empty or blank .
 * Otherwise original value is returned
 * @ param value Value to check .
 * @ param name Name of parameter , it will produce an error message such as " { name } must not be null "
 * or " { name } must not be blank " .
 * @ return First parameter if it is not blank . */
public static String notBlank ( String value , String name ) { } }

implementation: notNull ( value , name ) ; if ( Strings . isBlank ( value ) ) { throw new IllegalArgumentException ( format ( "%s must not be blank" , name ) ) ; } return value ;


signature:
public class OkHttpRequest { /** * Add all HTTP headers to the final request .
 * @ param builder The OkHttp request builder .
 * @ see Request . Builder # addHeader ( String , String ) */
private void handleHeaders ( Request . Builder builder ) { } }

implementation: for ( HttpHeader h : headers . values ( ) ) { builder . addHeader ( h . getName ( ) , h . serializeValues ( ) ) ; }


signature:
public class OkHttpRequest { /** * Add all cookies to the final request ( i . e add the { @ code Cookie } header ) .
 * @ param builder The OkHttp request builder .
 * @ see Request . Builder # addHeader ( String , String ) */
private void handleCookies ( Request . Builder builder ) { } }

implementation: if ( ! cookies . isEmpty ( ) ) { builder . addHeader ( HttpHeaders . COOKIE , Cookies . serialize ( cookies ) ) ; }


signature:
public class OkHttpRequest { /** * Add request body if appropriate :
 * < ul >
 * < li > Add request body if { @ link # body } is defined . < / li >
 * < li > Add form parameters ( { @ link # formParams } otherwise if it is not empty . < / li >
 * < / ul >
 * @ param builder The native OkHttp request builder .
 * @ see Request . Builder # method ( String , RequestBody )
 * @ see RequestBody */
private void handleBody ( Request . Builder builder ) { } }

implementation:
HttpMethod method = getMethod ( ) ; RequestBody body = hasBody ( ) ? createBody ( ) : null ; // Force an empty body , as POST & PUT methods requires
// a body element .
if ( body == null && method . isBodyAllowed ( ) ) { body = createEmptyBody ( ) ; } builder . method ( method . getVerb ( ) , body ) ;


signature:
public class OkHttpRequest { /** * Create the OkHttp request body :
 * < ul >
 * < li > Create body from { @ link # body } value if it is defined . < / li >
 * < li > Create { @ link FormBody } from { @ link # formParams } otherwise if it is not empty . < / li >
 * < li > Returns { @ code null } otherwise . < / li >
 * < / ul >
 * @ return OkHttp { @ link RequestBody } instance .
 * @ see RequestBody # create ( MediaType , String )
 * @ see FormBody */
private RequestBody createBody ( ) { } }

implementation:
RequestBody rqBody = null ; // Try request body first .
if ( body != null && ! body . isEmpty ( ) ) { rqBody = RequestBody . create ( null , body ) ; } else if ( ! formParams . isEmpty ( ) ) { FormBody . Builder builder = new FormBody . Builder ( ) ; for ( HttpParameter parameter : formParams . values ( ) ) { String encodedName = parameter . getEncodedName ( ) ; String encodedValue = firstNonNull ( parameter . getEncodedValue ( ) , "" ) ; builder . addEncoded ( encodedName , encodedValue ) ; } rqBody = builder . build ( ) ; } return rqBody ;


signature:
public class Strings { /** * Check that given string is blank .
 * @ param value String to check .
 * @ return { @ code true } if string is blank , { @ code false } otherwise . */
static boolean isBlank ( String value ) { } }

implementation: if ( value == null ) { return true ; } for ( char character : value . toCharArray ( ) ) { if ( ! Character . isWhitespace ( character ) ) { return false ; } } return true ;


signature:
public class Strings { /** * Remove string prefix if and only if string value starts with
 * the prefix , otherwise original string is returned .
 * @ param value String value .
 * @ param prefix String prefix .
 * @ return New string . */
public static String removePrefix ( String value , String prefix ) { } }

implementation: if ( value == null || prefix == null || prefix . length ( ) > value . length ( ) ) { return value ; } return value . startsWith ( prefix ) ? value . substring ( prefix . length ( ) ) : value ;


signature:
public class Strings { /** * Join all strings to a single one using given separator .
 * @ param separator String separator .
 * @ param values All string to join .
 * @ return The final string . */
public static String join ( String separator , Collection < String > values ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; boolean first = true ; for ( String value : values ) { if ( ! first ) { builder . append ( separator ) ; } builder . append ( value ) ; first = false ; } return builder . toString ( ) ;


signature:
public class AsyncHttpRequest { /** * Add query parameter to the final HTTP request .
 * @ param builder The pending HTTP request .
 * @ see RequestBuilder # addQueryParam ( String , String ) */
private void handleQueryParameters ( RequestBuilder builder ) { } }

implementation: for ( HttpParameter p : queryParams . values ( ) ) { builder . addQueryParam ( p . getEncodedName ( ) , p . getEncodedValue ( ) ) ; }


signature:
public class AsyncHttpRequest { /** * Add body entity to the final HTTP request .
 * @ param builder The pending HTTP request .
 * @ see RequestBuilder # addFormParam ( String , String )
 * @ see RequestBuilder # setBody ( String ) */
private void handleBody ( RequestBuilder builder ) { } }

implementation: if ( ! hasBody ( ) ) { return ; } if ( body != null ) { handleRequestBody ( builder ) ; } else { handleFormParameters ( builder ) ; }


signature:
public class AsyncHttpRequest { /** * Serialize form parameters to the request body .
 * @ param builder The pending HTTP request .
 * @ see RequestBuilder # addFormParam ( String , String ) */
private void handleFormParameters ( RequestBuilder builder ) { } }

implementation: for ( HttpParameter p : formParams . values ( ) ) { builder . addFormParam ( p . getName ( ) , p . getValue ( ) ) ; }


signature:
public class AsyncHttpRequest { /** * Add cookies to the final HTTP request .
 * @ param builder The pending HTTP request .
 * @ see RequestBuilder # addCookie ( Cookie ) */
private void handleCookies ( RequestBuilder builder ) { } }


signature:
public class NingAsyncHttpRequest { /** * Add request headers .
 * @ param builder The pending HTTP request .
 * @ see RequestBuilder # addHeader ( String , String ) */
private void handleHeaders ( RequestBuilder builder ) { } }

implementation: for ( HttpHeader header : headers . values ( ) ) { builder . addHeader ( header . getName ( ) , header . serializeValues ( ) ) ; }


signature:
public class ToStringBuilder { /** * Append new map value .
 * @ param name The name of the field .
 * @ param map The map .
 * @ return The current builder ( for chaining ) . */
public ToStringBuilder append ( String name , Map < ? , ? > map ) { } }

implementation: StringBuilder sb = new StringBuilder ( START_OBJ ) ; for ( Map . Entry < ? , ? > entry : map . entrySet ( ) ) { sb . append ( entry . getKey ( ) ) . append ( FIELD_VALUE_SEPARATOR ) . append ( formatValue ( entry . getValue ( ) ) ) ; } sb . append ( END_OBJ ) ; return appendFormattedValue ( name , sb . toString ( ) ) ;


signature:
public class ToStringBuilder { /** * Append new boolean value .
 * @ param name The name of the field .
 * @ param values The collection of values .
 * @ param < T > Type of elements in collection .
 * @ return The current builder ( for chaining ) . */
public < T > ToStringBuilder append ( String name , Iterable < T > values ) { } }

implementation: StringBuilder pending = new StringBuilder ( ) . append ( OPEN_ARRAY ) ; boolean firstItem = true ; for ( T value : values ) { if ( ! firstItem ) { pending . append ( SEPARATOR ) ; } pending . append ( formatValue ( value ) ) ; firstItem = false ; } return appendFormattedValue ( name , pending . append ( CLOSE_ARRAY ) . toString ( ) ) ;


signature:
public class ToStringBuilder { /** * Format value ( i . e wrapped string with double quote for example ) , and append
 * the field the final output .
 * @ param name Field name .
 * @ param value The value .
 * @ return The current builder . */
private ToStringBuilder appendValue ( String name , Object value ) { } }

implementation: return appendFormattedValue ( name , formatValue ( value ) ) ;


signature:
public class ToStringBuilder { /** * Append formatted value to the final output .
 * @ param name Field name .
 * @ param value Field value .
 * @ return The current builder . */
private ToStringBuilder appendFormattedValue ( String name , Object value ) { } }

implementation: if ( ! first ) { sb . append ( SEPARATOR ) ; } sb . append ( name ) . append ( FIELD_VALUE_SEPARATOR ) . append ( value ) ; first = false ; return this ;


signature:
public class ToStringBuilder { /** * Format value :
 * < ul >
 * < li > Returns { @ code null } if { @ code value } is null . < / li >
 * < li > Wrapped value inside double quote if it is a string value . < / li >
 * < li > Returns the result of { @ code toString } function otherwise . < / li >
 * < / ul >
 * @ param value The value to raw .
 * @ return The formatted value . */
private static String formatValue ( Object value ) { } }

implementation: if ( value == null ) { return null ; } return value instanceof CharSequence ? "\"" + value + "\"" : value . toString ( ) ;


signature:
public class HttpUrl { /** * Parse URL string to create new { @ link HttpUrl } instance .
 * @ param endpoint URL value .
 * @ return The final { @ link HttpUrl } instance .
 * @ throws IllegalArgumentException If URL is malformed . */
public static HttpUrl parse ( String endpoint ) { } }

implementation: try { final URL url = new URL ( endpoint ) ; final String protocol = url . getProtocol ( ) ; final String host = url . getHost ( ) ; final int port = url . getPort ( ) ; final String path = url . getPath ( ) ; return new Builder ( ) . withScheme ( protocol ) . withHost ( host ) . withPort ( port >= 0 ? port : url . getDefaultPort ( ) ) . withPath ( path ) . build ( ) ; } catch ( MalformedURLException ex ) { throw new IllegalArgumentException ( ex ) ; }


signature:
public class HttpUrl { /** * Create new { @ link URI } from URL fields .
 * @ return URI instance .
 * @ throws IllegalArgumentException If { @ code URI } cannot be built because of { @ link URISyntaxException } . */
public URI toURI ( ) { } }

implementation: final String protocol = scheme . getProtocol ( ) ; try { return new URI ( protocol , null , host , port , path , null , null ) ; } catch ( URISyntaxException ex ) { throw new UrlException ( protocol , host , port , path , ex ) ; }


signature:
public class EncoderUtils { /** * Translates a string into { @ code application / x - www - form - urlencoded }
 * format using UTF - 8 encoding .
 * @ param value The string value .
 * @ return The encoded value .
 * @ throws Utf8EncodingException If , for some weird reason , UTF - 8 encoding is not supported . */
public static String urlEncode ( String value ) { } }

implementation: try { return URLEncoder . encode ( value , StandardCharsets . UTF_8 . displayName ( ) ) ; } catch ( UnsupportedEncodingException ex ) { throw new Utf8EncodingException ( ex ) ; }


signature:
public class LazySeq { /** * Returns a string representation of this { @ link LazySeq } .
 * The string result starts with the string < code > start < / code > and ends with < code > end < / code > ,
 * whereas < code > sep < / code > is as separator string between the elements of this sequence . */
public String mkString ( String start , String sep , String end ) { } }

implementation: return mkString ( start , sep , end , false ) ;


signature:
public class LazySeq { /** * Returns a string representation of this { @ link LazySeq } .
 * The string result starts with the string < code > start < / code > and ends with < code > end < / code > ,
 * whereas < code > sep < / code > is as separator string between the elements of this sequence .
 * If < code > lazy < / code > is < code > true < / code > the evaluation stops at the first unspecific element . */
public String mkString ( String start , String sep , String end , boolean lazy ) { } }

implementation: final StringBuilder s = new StringBuilder ( start ) ; LazySeq < E > cur = this ; while ( ! cur . isEmpty ( ) ) { s . append ( cur . head ( ) ) ; if ( ! lazy || cur . isTailDefined ( ) ) { if ( ! cur . tail ( ) . isEmpty ( ) ) { s . append ( sep ) ; } cur = cur . tail ( ) ; } else { s . append ( sep ) . append ( "?" ) ; break ; } } return s . append ( end ) . toString ( ) ;


signature:
public class SIPDialogCacheData { /** * Update the haSipDialog passed in param with the dialogMetaData and app meta data
 * @ param dialogMetaData
 * @ param dialogAppData
 * @ param haSipDialog
 * @ throws ParseException
 * @ throws PeerUnavailableException */
private void updateDialogMetaData ( Map < String , Object > dialogMetaData , Object dialogAppData , HASipDialog haSipDialog , boolean recreation ) throws ParseException , PeerUnavailableException { } }

implementation: haSipDialog . setMetaDataToReplicate ( dialogMetaData , recreation ) ; haSipDialog . setApplicationDataToReplicate ( dialogAppData ) ; final String contactStringified = ( String ) dialogMetaData . get ( AbstractHASipDialog . CONTACT_HEADER ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "contactStringified " + contactStringified ) ; } if ( contactStringified != null ) { Address contactAddress = SipFactory . getInstance ( ) . createAddressFactory ( ) . createAddress ( contactStringified ) ; ContactHeader contactHeader = SipFactory . getInstance ( ) . createHeaderFactory ( ) . createContactHeader ( contactAddress ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "contactHeader " + contactHeader ) ; logger . logDebug ( "contactURI " + contactHeader . getAddress ( ) . getURI ( ) ) ; } haSipDialog . setContactHeader ( contactHeader ) ; }


signature:
public class SIPServerTransactionCacheData { /** * Update the haSipDialog passed in param with the dialogMetaData and app meta data
 * @ param transactionMetaData
 * @ param transactionAppData
 * @ param haServerTransaction
 * @ throws ParseException
 * @ throws PeerUnavailableException */
private void updateServerTransactionMetaData ( Map < String , Object > transactionMetaData , Object transactionAppData , MobicentsHASIPServerTransaction haServerTransaction , boolean recreation ) throws ParseException , PeerUnavailableException { } }

implementation: haServerTransaction . setMetaDataToReplicate ( transactionMetaData , recreation ) ; haServerTransaction . setApplicationDataToReplicate ( transactionAppData ) ;


signature:
public class JBossSipCache { /** * / * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # getDialog ( java . lang . String ) */
public SIPDialog getDialog ( String dialogId ) throws SipCacheException { } }

implementation: try { Node dialogNode = ( ( Node ) dialogRootNode . getChild ( Fqn . fromString ( dialogId ) ) ) ; if ( dialogNode != null ) { return ( SIPDialog ) dialogNode . get ( dialogId ) ; } else { return null ; } } catch ( CacheException e ) { throw new SipCacheException ( "A problem occured while retrieving the following dialog " + dialogId + " from JBoss Cache" , e ) ; }


signature:
public class JBossSipCache { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # updateDialog ( gov . nist . javax . sip . stack . SIPDialog ) */
public void updateDialog ( SIPDialog sipDialog ) throws SipCacheException { } }

implementation: Node dialogNode = ( ( Node ) dialogRootNode . getChild ( Fqn . fromString ( sipDialog . getDialogId ( ) ) ) ) ; if ( dialogNode != null ) { if ( dialogNode != null ) { sipDialog = ( SIPDialog ) dialogNode . get ( sipDialog . getDialogId ( ) ) ; } }


signature:
public class JBossSipCache { /** * / * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # putDialog ( gov . nist . javax . sip . stack . SIPDialog ) */
public void putDialog ( SIPDialog dialog ) throws SipCacheException { } }

implementation: UserTransaction tx = null ; try { Properties prop = new Properties ( ) ; prop . put ( Context . INITIAL_CONTEXT_FACTORY , "org.jboss.cache.transaction.DummyContextFactory" ) ; tx = ( UserTransaction ) new InitialContext ( prop ) . lookup ( "UserTransaction" ) ; if ( tx != null ) { tx . begin ( ) ; } Node dialogNode = dialogRootNode . addChild ( Fqn . fromString ( dialog . getDialogId ( ) ) ) ; dialogNode . put ( dialog . getDialogId ( ) , dialog ) ; if ( tx != null ) { tx . commit ( ) ; } } catch ( Exception e ) { if ( tx != null ) { try { tx . rollback ( ) ; } catch ( Throwable t ) { } } throw new SipCacheException ( "A problem occured while putting the following dialog " + dialog . getDialogId ( ) + "  into JBoss Cache" , e ) ; }


signature:
public class JBossSipCache { /** * / * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # removeDialog ( java . lang . String ) */
public void removeDialog ( String dialogId ) throws SipCacheException { } }

implementation: UserTransaction tx = null ; try { Properties prop = new Properties ( ) ; prop . put ( Context . INITIAL_CONTEXT_FACTORY , "org.jboss.cache.transaction.DummyContextFactory" ) ; tx = ( UserTransaction ) new InitialContext ( prop ) . lookup ( "UserTransaction" ) ; if ( tx != null ) { tx . begin ( ) ; } dialogRootNode . removeChild ( dialogId ) ; if ( tx != null ) { tx . commit ( ) ; } } catch ( Exception e ) { if ( tx != null ) { try { tx . rollback ( ) ; } catch ( Throwable t ) { } } throw new SipCacheException ( "A problem occured while removing the following dialog " + dialogId + " from JBoss Cache" , e ) ; }


signature:
public class ManagedMobicentsSipCache { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . MobicentsSipCache # stop ( ) */
@ Override public void stop ( ) throws SipCacheException { } }

implementation: if ( configProperties . getProperty ( ManagedMobicentsSipCache . STANDALONE ) != null || "true" . equals ( configProperties . getProperty ( ManagedMobicentsSipCache . STANDALONE ) ) ) { super . stop ( ) ; }


signature:
public class AbstractLoadBalancerElector { /** * Creates a { @ link Address } with a { @ link SipUri } , from the specified
 * balancer description . Note that the uri has no transport set .
 * @ param balancerDescription
 * @ return */
private Address createAddress ( String balancerDescription ) { } }

implementation: String host = balancerDescription ; int sipPort = LoadBalancerHeartBeatingServiceImpl . DEFAULT_LB_SIP_PORT ; if ( balancerDescription . indexOf ( LoadBalancerHeartBeatingServiceImpl . BALANCER_SIP_PORT_CHAR_SEPARATOR ) != - 1 ) { String [ ] balancerDescriptionSplitted = balancerDescription . split ( LoadBalancerHeartBeatingServiceImpl . BALANCER_SIP_PORT_CHAR_SEPARATOR ) ; host = balancerDescriptionSplitted [ 0 ] ; try { sipPort = Integer . parseInt ( balancerDescriptionSplitted [ 1 ] ) ; } catch ( NumberFormatException e ) { logger . logError ( "Impossible to parse the following sip balancer port " + balancerDescriptionSplitted [ 1 ] , e ) ; return null ; } } return createAddress ( host , sipPort ) ;


signature:
public class AbstractLoadBalancerElector { /** * Creates a { @ link Address } with a { @ link SipUri } , from the specified host
 * and port . Note that the uri has no transport set .
 * @ param host
 * @ param port
 * @ return */
private Address createAddress ( String host , int port ) { } }

implementation: SipUri sipUri = new SipUri ( ) ; try { sipUri . setHost ( host ) ; } catch ( ParseException e ) { logger . logError ( "Bad load balancer host " + host , e ) ; return null ; } sipUri . setPort ( port ) ; return addressFactory . createAddress ( sipUri ) ;


signature:
public class AbstractLoadBalancerElector { /** * ( non - Javadoc )
 * @ seeorg . mobicents . ha . javax . sip . LoadBalancerHeartBeatingListener #
 * loadBalancerRemoved ( org . mobicents . ha . javax . sip . SipLoadBalancer ) */
public void loadBalancerRemoved ( SipLoadBalancer balancerDescription ) { } }

implementation: Address address = createAddress ( balancerDescription . getAddress ( ) . getHostName ( ) , balancerDescription . getSipPort ( ) ) ; if ( address != null ) { removeLoadBalancer ( address ) ; }


signature:
public class AbstractLoadBalancerElector { /** * / * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . LoadBalancerElector # setService ( org . mobicents . ha . javax . sip . LoadBalancerHeartBeatingService ) */
public void setService ( LoadBalancerHeartBeatingService service ) throws IllegalStateException , NullPointerException { } }

implementation: if ( service == null ) { throw new NullPointerException ( "null service" ) ; } if ( addressFactory == null || logger == null ) { throw new IllegalStateException ( ) ; } this . service = service ; service . addLoadBalancerHeartBeatingListener ( this ) ; for ( SipLoadBalancer balancer : service . getLoadBalancers ( ) ) { addLoadBalancer ( balancer ) ; }


signature:
public class SipStackImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . ClusteredSipStack # passivateDialog ( org . mobicents . ha . javax . sip . HASipDialog ) */
public void passivateDialog ( HASipDialog dialog ) { } }

implementation: String dialogId = dialog . getDialogIdToReplicate ( ) ; sipCache . evictDialog ( dialogId ) ; String mergeId = dialog . getMergeId ( ) ; if ( mergeId != null ) { serverDialogMergeTestTable . remove ( mergeId ) ; } dialogTable . remove ( dialogId ) ;


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . SipStackImpl # start ( ) */
@ Override public void start ( ) throws ProviderDoesNotExistException , SipException { } }

implementation: try { sipCache . start ( ) ; } catch ( Exception e ) { throw new SipException ( "Unable to start the SipCache" , e ) ; } if ( loadBalancerHeartBeatingService != null ) { loadBalancerHeartBeatingService . start ( ) ; } super . start ( ) ;


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . SipStackImpl # stop ( ) */
@ Override public void stop ( ) { } }

implementation: super . stop ( ) ; try { sipCache . stop ( ) ; } catch ( Exception e ) { getStackLogger ( ) . logError ( "Unable to stop the SipCache" , e ) ; } if ( loadBalancerHeartBeatingService != null ) { loadBalancerHeartBeatingService . stop ( ) ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # createDialog ( gov . nist . javax . sip . stack . SIPTransaction ) */
@ Override public SIPDialog createDialog ( SIPTransaction transaction ) { } }

implementation: if ( sipCache . inLocalMode ( ) ) { return super . createDialog ( transaction ) ; } else { SIPDialog retval = null ; if ( transaction instanceof SIPClientTransaction ) { final String dialogId = ( ( SIPRequest ) transaction . getRequest ( ) ) . getDialogId ( false ) ; retval = this . earlyDialogTable . get ( dialogId ) ; if ( retval == null || ( retval . getState ( ) != null && retval . getState ( ) != DialogState . EARLY ) ) { retval = ( SIPDialog ) HASipDialogFactory . createHASipDialog ( replicationStrategy , transaction ) ; this . earlyDialogTable . put ( dialogId , retval ) ; } } else { retval = ( SIPDialog ) HASipDialogFactory . createHASipDialog ( replicationStrategy , transaction ) ; } return retval ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # createDialog ( gov . nist . javax . sip . stack . SIPClientTransaction , gov . nist . javax . sip . message . SIPResponse ) */
@ Override public SIPDialog createDialog ( SIPClientTransaction transaction , SIPResponse sipResponse ) { } }

implementation: if ( sipCache . inLocalMode ( ) ) { return super . createDialog ( transaction , sipResponse ) ; } else { final String dialogId = ( ( SIPRequest ) transaction . getRequest ( ) ) . getDialogId ( false ) ; SIPDialog retval = this . earlyDialogTable . get ( dialogId ) ; if ( retval != null && sipResponse . isFinalResponse ( ) ) { this . earlyDialogTable . remove ( dialogId ) ; } else { retval = ( SIPDialog ) HASipDialogFactory . createHASipDialog ( replicationStrategy , transaction , sipResponse ) ; } return retval ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # createDialog ( gov . nist . javax . sip . SipProviderImpl , gov . nist . javax . sip . message . SIPResponse ) */
@ Override public SIPDialog createDialog ( SipProviderImpl sipProvider , SIPResponse sipResponse ) { } }

implementation: if ( sipCache . inLocalMode ( ) ) { return super . createDialog ( sipProvider , sipResponse ) ; } else { return ( SIPDialog ) HASipDialogFactory . createHASipDialog ( replicationStrategy , sipProvider , sipResponse ) ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # getDialog ( java . lang . String ) */
@ Override public SIPDialog getDialog ( String dialogId ) { } }

implementation:
if ( sipCache . inLocalMode ( ) ) { return super . getDialog ( dialogId ) ; } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "checking if the dialog " + dialogId + " is present in the local cache" ) ; } SIPDialog sipDialog = super . getDialog ( dialogId ) ; int nbToken = new StringTokenizer ( dialogId , Separators . COLON ) . countTokens ( ) ; // we should only check the cache for dialog Id where the remote tag is set since we support only established dialog failover
// Issue 1378 : http : / / code . google . com / p / restcomm / issues / detail ? id = 1378
// there can be more than 3 tokens if the callid part of the dialog id contains a COLON as well
if ( nbToken >= 3 ) { if ( sipDialog == null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "local dialog " + dialogId + " is null, checking in the distributed cache" ) ; } sipDialog = getDialogFromDistributedCache ( dialogId ) ; if ( sipDialog != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "dialog " + dialogId + " found in the distributed cache, storing it locally" ) ; } SIPDialog existingDialog = super . putDialog ( sipDialog ) ; // avoid returning wrong dialog if 2 threads try to recreate
// the dialog after failover , we use the one that won the race
if ( existingDialog != null ) { sipDialog = existingDialog ; } } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "dialog " + dialogId + " not found in the distributed cache" ) ; } } } else { // we check for updates only if the dialog is confirmed
if ( sipDialog . getState ( ) == DialogState . CONFIRMED ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "local dialog " + dialogId + " is present locally " + sipDialog + " checking if it needs to be updated from the cache" ) ; } try { sipCache . updateDialog ( sipDialog ) ; } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem updating dialog " + dialogId + " from the distributed cache" , e ) ; } } } } return sipDialog ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # removeDialog ( gov . nist . javax . sip . stack . SIPDialog ) */
@ Override public void removeDialog ( SIPDialog dialog ) { } }

implementation: if ( ! sipCache . inLocalMode ( ) ) { removeDialogFromDistributedCache ( dialog . getDialogId ( ) ) ; } super . removeDialog ( dialog ) ;


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . ClusteredSipStack # remoteDialogRemoval ( java . lang . String ) */
public void remoteDialogRemoval ( String dialogId ) { } }

implementation:
// note we don ' t want a dialog terminated event , thus we need to go directly to map removal
// assuming it ' s a confirmed dialog there is no chance it is on early dialogs too
if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " remote Dialog Removal of dialogId : " + dialogId ) ; } SIPDialog sipDialog = super . dialogTable . remove ( dialogId ) ; if ( sipDialog != null ) { String mergeId = sipDialog . getMergeId ( ) ; if ( mergeId != null ) { super . serverDialogMergeTestTable . remove ( mergeId ) ; } }


signature:
public class ClusteredSipStackImpl { /** * Retrieve the dialog from the distributed cache
 * @ param dialogId the id of the dialog to fetch
 * @ return the SIPDialog from the distributed cache , null if nothing has been found in the cache */
protected SIPDialog getDialogFromDistributedCache ( String dialogId ) { } }

implementation:
if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " checking if the dialog " + dialogId + " is present in the distributed cache" ) ; } // fetch the corresponding dialog from the cache instance
SIPDialog sipDialog = null ; try { sipDialog = sipCache . getDialog ( dialogId ) ; } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem getting dialog " + dialogId + " from the distributed cache" , e ) ; } if ( sipDialog != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " dialog " + dialogId + " was present in the distributed cache, initializing it after the load" ) ; } ( ( HASipDialog ) sipDialog ) . initAfterLoad ( this ) ; } return sipDialog ;


signature:
public class ClusteredSipStackImpl { /** * Store the dialog into the distributed cache
 * @ param dialog the dialog to store */
protected void putDialogIntoDistributedCache ( SIPDialog dialog ) { } }

implementation:
String dialogId = dialog . getDialogId ( ) ; if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " storing the dialog " + dialogId + " in the distributed cache" ) ; } // put the corresponding dialog into the cache instance
try { sipCache . putDialog ( dialog ) ; } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem storing the dialog " + dialogId + " into the distributed cache" , e ) ; }


signature:
public class ClusteredSipStackImpl { /** * Remove the dialog from the distributed cache
 * @ param dialogId the id of the dialog to remove */
protected void removeDialogFromDistributedCache ( String dialogId ) { } }

implementation:
if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " removing the dialog " + dialogId + " from the distributed cache" ) ; } // remove the corresponding dialog from the cache instance
// put the corresponding dialog into the cache instance
try { sipCache . removeDialog ( dialogId ) ; } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem removing dialog " + dialogId + " from the distributed cache" , e ) ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see gov . nist . javax . sip . stack . SIPTransactionStack # findTransaction ( java . lang . String , boolean ) */
@ Override public SIPTransaction findTransaction ( String transactionId , boolean isServer ) { } }

implementation:
if ( sipCache . inLocalMode ( ) || replicationStrategy != ReplicationStrategy . EarlyDialog ) { return super . findTransaction ( transactionId , isServer ) ; } final String txId = transactionId . toLowerCase ( ) ; SIPTransaction sipTransaction = super . findTransaction ( txId , isServer ) ; if ( sipTransaction == null && transactionFactory != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "local transaction " + txId + " server = " + isServer + " is null, checking in the distributed cache" ) ; } if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " checking if the transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } if ( isServer ) { // fetch the corresponding server transaction from the cache instance
try { sipTransaction = sipCache . getServerTransaction ( txId ) ; if ( sipTransaction != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } SIPServerTransaction retval = serverTransactionTable . putIfAbsent ( txId , ( SIPServerTransaction ) sipTransaction ) ; if ( retval != null ) { sipTransaction = retval ; } } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache" ) ; } } } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache" , e ) ; } } else { // fetch the corresponding client transaction from the cache instance
try { sipTransaction = sipCache . getClientTransaction ( txId ) ; if ( sipTransaction != null ) { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache" ) ; } SIPClientTransaction retval = clientTransactionTable . putIfAbsent ( txId , ( SIPClientTransaction ) sipTransaction ) ; if ( retval != null ) { sipTransaction = retval ; } else { // start the transaction timer only when the transaction has been added to the stack
// to avoid leaks on retransmissions
( ( MobicentsHASIPClientTransaction ) sipTransaction ) . startTransactionTimerOnFailover ( ) ; } } else { if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache" ) ; } } } catch ( SipCacheException e ) { getStackLogger ( ) . logError ( "sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache" , e ) ; } } } return sipTransaction ;


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . ClusteredSipStack # remoteServerTransactionRemoval ( java . lang . String ) */
public void remoteServerTransactionRemoval ( String transactionId ) { } }

implementation:
final String txId = transactionId . toLowerCase ( ) ; // note we don ' t want a dialog terminated event , thus we need to go directly to map removal
// assuming it ' s a confirmed dialog there is no chance it is on early dialogs too
if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " remote Server Transaction Removal of transaction Id : " + txId ) ; } // the transaction id is set to lower case in the cache so it might not remove it correctly
SIPServerTransaction sipServerTransaction = super . serverTransactionTable . remove ( txId ) ; if ( sipServerTransaction != null ) { super . removeFromMergeTable ( sipServerTransaction ) ; super . removePendingTransaction ( sipServerTransaction ) ; super . removeTransactionPendingAck ( sipServerTransaction ) ; }


signature:
public class ClusteredSipStackImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . ClusteredSipStack # remoteClientTransactionRemoval ( java . lang . String ) */
public void remoteClientTransactionRemoval ( String transactionId ) { } }

implementation:
final String txId = transactionId . toLowerCase ( ) ; // note we don ' t want a dialog terminated event , thus we need to go directly to map removal
// assuming it ' s a confirmed dialog there is no chance it is on early dialogs too
if ( getStackLogger ( ) . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { getStackLogger ( ) . logDebug ( "sipStack " + this + " remote Client Transaction Removal of transaction Id : " + txId ) ; } // the transaction id is set to lower case in the cache so it might not remove it correctly
SIPClientTransaction sipClientTransaction = super . clientTransactionTable . remove ( txId ) ;


signature:
public class SIPClientTransactionCacheData { /** * Update the haSipDialog passed in param with the dialogMetaData and app meta data
 * @ param transactionMetaData
 * @ param transactionAppData
 * @ param haClientTransaction
 * @ throws ParseException
 * @ throws PeerUnavailableException */
private void updateClientTransactionMetaData ( Map < String , Object > transactionMetaData , Object transactionAppData , MobicentsHASIPClientTransaction haClientTransaction , boolean recreation ) throws ParseException , PeerUnavailableException { } }

implementation: haClientTransaction . setMetaDataToReplicate ( transactionMetaData , recreation ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "updating application data with the one from cache " + transactionAppData ) ; } haClientTransaction . setApplicationDataToReplicate ( transactionAppData ) ;


signature:
public class RoundRobinLoadBalancerElector { /** * Computes the index of the next balancer to retrieve . Adaptation of the { @ link AtomicInteger } incrementAndGet ( ) code .
 * @ return */
private int getNextIndex ( ) { } }

implementation: for ( ; ; ) { int current = index . get ( ) ; int next = ( current == balancers . size ( ) ? 1 : current + 1 ) ; if ( index . compareAndSet ( current , next ) ) return next - 1 ; }


signature:
public class MobicentsSipCache { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # start ( ) */
public void start ( ) throws SipCacheException { } }

implementation: cluster . getMobicentsCache ( ) . startCache ( ) ; dialogsCacheData = new SIPDialogCacheData ( Fqn . fromElements ( name , SipCache . DIALOG_PARENT_FQN_ELEMENT ) , cluster . getMobicentsCache ( ) , clusteredSipStack ) ; dialogsCacheData . create ( ) ; dialogDataRemovalListener = new DialogDataRemovalListener ( dialogsCacheData . getNodeFqn ( ) , clusteredSipStack ) ; cluster . addDataRemovalListener ( dialogDataRemovalListener ) ; if ( clusteredSipStack . getReplicationStrategy ( ) == ReplicationStrategy . EarlyDialog ) { serverTransactionCacheData = new ServerTransactionCacheData ( Fqn . fromElements ( name , SipCache . SERVER_TX_PARENT_FQN_ELEMENT ) , cluster . getMobicentsCache ( ) , clusteredSipStack ) ; serverTransactionCacheData . create ( ) ; serverTransactionDataRemovalListener = new ServerTransactionDataRemovalListener ( serverTransactionCacheData . getNodeFqn ( ) , clusteredSipStack ) ; cluster . addDataRemovalListener ( serverTransactionDataRemovalListener ) ; clientTransactionCacheData = new ClientTransactionCacheData ( Fqn . fromElements ( name , SipCache . CLIENT_TX_PARENT_FQN_ELEMENT ) , cluster . getMobicentsCache ( ) , clusteredSipStack ) ; clientTransactionCacheData . create ( ) ; clientTransactionDataRemovalListener = new ClientTransactionDataRemovalListener ( clientTransactionCacheData . getNodeFqn ( ) , clusteredSipStack ) ; cluster . addDataRemovalListener ( clientTransactionDataRemovalListener ) ; } if ( serializationClassLoader != null ) { Region region = getMobicentsCache ( ) . getJBossCache ( ) . getRegion ( dialogsCacheData . getNodeFqn ( ) , true ) ; region . registerContextClassLoader ( serializationClassLoader ) ; region . activate ( ) ; if ( clusteredSipStack . getReplicationStrategy ( ) == ReplicationStrategy . EarlyDialog ) { Region stxRegion = getMobicentsCache ( ) . getJBossCache ( ) . getRegion ( serverTransactionCacheData . getNodeFqn ( ) , true ) ; stxRegion . registerContextClassLoader ( serializationClassLoader ) ; stxRegion . activate ( ) ; Region ctxRegion = getMobicentsCache ( ) . getJBossCache ( ) . getRegion ( clientTransactionCacheData . getNodeFqn ( ) , true ) ; ctxRegion . registerContextClassLoader ( serializationClassLoader ) ; ctxRegion . activate ( ) ; } }


signature:
public class MobicentsSipCache { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . cache . SipCache # stop ( ) */
public void stop ( ) throws SipCacheException { } }

implementation: dialogsCacheData . remove ( ) ; cluster . removeDataRemovalListener ( dialogDataRemovalListener ) ; if ( clusteredSipStack . getReplicationStrategy ( ) == ReplicationStrategy . EarlyDialog ) { serverTransactionCacheData . remove ( ) ; cluster . removeDataRemovalListener ( serverTransactionDataRemovalListener ) ; clientTransactionCacheData . remove ( ) ; cluster . removeDataRemovalListener ( clientTransactionDataRemovalListener ) ; }


signature:
public class MobicentsHATransactionFactory { /** * / * ( non - Javadoc )
 * @ see org . mobicents . ext . javax . sip . TransactionFactory # createClientTransaction ( gov . nist . javax . sip . message . SIPRequest , gov . nist . javax . sip . stack . MessageChannel ) */
public SIPClientTransaction createClientTransaction ( SIPRequest sipRequest , MessageChannel encapsulatedMessageChannel ) { } }

implementation: MobicentsHASIPClientTransaction ct = new MobicentsHASIPClientTransaction ( sipStack , encapsulatedMessageChannel ) ; ct . setOriginalRequest ( sipRequest ) ; return ct ;


signature:
public class AbstractHASipDialog { /** * Updates the local dialog transient attributes that were not serialized during the replication
 * @ param sipStackImpl the sip Stack Impl that reloaded this dialog from the distributed cache */
public void initAfterLoad ( ClusteredSipStack sipStackImpl ) { } }

implementation: String transport = getLastResponseTopMostVia ( ) . getTransport ( ) ; Iterator < SipProviderImpl > providers = sipStackImpl . getSipProviders ( ) ; boolean providerNotFound = true ; while ( providers . hasNext ( ) ) { SipProviderImpl providerImpl = providers . next ( ) ; if ( providerImpl . getListeningPoint ( transport ) != null ) { setSipProvider ( providerImpl ) ; providerNotFound = false ; } } if ( providerNotFound ) { throw new RuntimeException ( "No providers found for transport=" + transport + " on this node. Make sure connectors are configured for this transport" ) ; } setStack ( ( SIPTransactionStack ) sipStackImpl ) ; setAssigned ( ) ; firstTransactionPort = getSipProvider ( ) . getListeningPoint ( getLastResponseTopMostVia ( ) . getTransport ( ) ) . getPort ( ) ; ackProcessed = true ; // ackSeen = true ;


signature:
public class AbstractHASipDialog { /** * From and To Uris switch places in certain conditions */
@ Override public boolean addTransaction ( SIPTransaction transaction ) { } }

implementation: if ( transaction instanceof ServerTransaction ) { isLatestTxServer = true ; } else { isLatestTxServer = false ; } return super . addTransaction ( transaction ) ;


signature: public class ConfirmedNoAppDataReplicationSipDialog { protected void replicateState ( ) { } }

implementation:
final DialogState dialogState = getState ( ) ; final ReplicationStrategy replicationStrategy = ( ( ClusteredSipStack ) getStack ( ) ) . getReplicationStrategy ( ) ; boolean replicationStateVsDialogStateOK = false ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "dialogState = " + dialogState + ", replicationStrategy = " + replicationStrategy ) ; } if ( dialogState == DialogState . CONFIRMED && ( replicationStrategy == ReplicationStrategy . ConfirmedDialog || replicationStrategy == ReplicationStrategy . ConfirmedDialogNoApplicationData ) ) { replicationStateVsDialogStateOK = true ; } if ( ( dialogState == DialogState . EARLY || dialogState == DialogState . CONFIRMED || // Added as part of https : / / github . com / Mobicents / jain - sip . ha / pull / 1
dialogState == DialogState . TERMINATED ) && replicationStrategy == ReplicationStrategy . EarlyDialog ) { replicationStateVsDialogStateOK = true ; } if ( replicationStateVsDialogStateOK && isCreated && super . dialogId != null && isRemoteTagSet ( ) && isLocalTagSet ( ) && getStack ( ) . getDialog ( getDialogIdToReplicate ( ) ) != null ) { try { ( ( ClusteredSipStack ) getStack ( ) ) . getSipCache ( ) . putDialog ( this ) ; } catch ( SipCacheException e ) { logger . logError ( "problem storing dialog " + getDialogId ( ) + " into the distributed cache" , e ) ; } }


signature:
public class MultiNetworkLoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public void setHeartBeatInterval ( long heartBeatInterval ) { } }

implementation:
if ( heartBeatInterval < 100 ) return ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "Setting HeartBeatInterval from " + this . heartBeatInterval + " to " + heartBeatInterval ) ; } this . heartBeatInterval = heartBeatInterval ; // if ( sipNodes . isEmpty ( ) ) {
// logger . logInfo ( " Computing SIP Nodes to be sent to the LB " ) ;
// updateConnectorsAsSIPNode ( ) ;
this . hearBeatTaskToRun . cancel ( ) ; this . hearBeatTaskToRun = new BalancerPingTimerTask ( ) ; this . heartBeatTimer . scheduleAtFixedRate ( this . hearBeatTaskToRun , 0 , this . heartBeatInterval ) ;


signature:
public class MultiNetworkLoadBalancerHeartBeatingServiceImpl { /** * Contribution from Naoki Nishihara from OKI for Issue 1806 ( SIP LB can not forward when node is listening on 0.0.0.0)
 * Useful for a multi homed address , tries to reach a given load balancer from the list of ip addresses given in param
 * @ param balancerAddr the load balancer to try to reach
 * @ param info the list of node info from which we try to access the load balancer
 * @ return the list stripped from the nodes not able to reach the load balancer */
protected ArrayList < SIPNode > getReachableSIPNodeInfo ( InetAddress balancerAddr , ArrayList < SIPNode > info ) { } }

implementation:
if ( balancerAddr . isLoopbackAddress ( ) ) { return info ; } ArrayList < SIPNode > rv = new ArrayList < SIPNode > ( ) ; for ( SIPNode node : info ) { if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Checking if " + node + " is reachable" ) ; } try { NetworkInterface ni = NetworkInterface . getByInetAddress ( InetAddress . getByName ( node . getIp ( ) ) ) ; // FIXME How can I determine the ttl ?
boolean b = balancerAddr . isReachable ( ni , 5 , 900 ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( node + " is reachable ? " + b ) ; } if ( b ) { rv . add ( node ) ; } } catch ( IOException e ) { logger . logError ( "IOException" , e ) ; } } if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]" ) ; } return rv ;


signature:
public class MultiNetworkLoadBalancerHeartBeatingServiceImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . ha . javax . sip . LoadBalancerHeartBeatingService # sendSwitchoverInstruction ( org . mobicents . ha . javax . sip . SipLoadBalancer , java . lang . String , java . lang . String ) */
public void sendSwitchoverInstruction ( SipLoadBalancer sipLoadBalancer , String fromJvmRoute , String toJvmRoute ) { } }

implementation: if ( logger . isLoggingEnabled ( StackLogger . TRACE_INFO ) ) { logger . logInfo ( "switching over from " + fromJvmRoute + " to " + toJvmRoute ) ; } if ( fromJvmRoute == null || toJvmRoute == null ) { return ; } ClassLoader oldClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( NodeRegisterRMIStub . class . getClassLoader ( ) ) ; Registry registry = LocateRegistry . getRegistry ( sipLoadBalancer . getAddress ( ) . getHostAddress ( ) , sipLoadBalancer . getRmiPort ( ) ) ; NodeRegisterRMIStub reg = ( NodeRegisterRMIStub ) registry . lookup ( "SIPBalancer" ) ; reg . switchover ( fromJvmRoute , toJvmRoute ) ; sipLoadBalancer . setDisplayWarning ( true ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_INFO ) && ! sipLoadBalancer . isAvailable ( ) ) { logger . logInfo ( "Switchover: SIP Load Balancer Found! " + sipLoadBalancer ) ; } } catch ( IOException e ) { sipLoadBalancer . setAvailable ( false ) ; if ( sipLoadBalancer . isDisplayWarning ( ) ) { logger . logWarning ( "Cannot access the SIP load balancer RMI registry: " + e . getMessage ( ) + "\nIf you need a cluster configuration make sure the SIP load balancer is running." ) ; sipLoadBalancer . setDisplayWarning ( false ) ; } } catch ( Exception e ) { sipLoadBalancer . setAvailable ( false ) ; if ( sipLoadBalancer . isDisplayWarning ( ) ) { logger . logError ( "Cannot access the SIP load balancer RMI registry: " + e . getMessage ( ) + "\nIf you need a cluster configuration make sure the SIP load balancer is running." , e ) ; sipLoadBalancer . setDisplayWarning ( false ) ; } } finally { Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ; }


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public void setHeartBeatInterval ( long heartBeatInterval ) { } }

implementation: if ( heartBeatInterval < 100 ) return ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "Setting HeartBeatInterval from " + this . heartBeatInterval + " to " + heartBeatInterval ) ; } this . heartBeatInterval = heartBeatInterval ; if ( sipNodes . isEmpty ( ) ) { logger . logInfo ( "Computing SIP Nodes to be sent to the LB" ) ; updateConnectorsAsSIPNode ( ) ; } this . hearBeatTaskToRun . cancel ( ) ; this . hearBeatTaskToRun = new BalancerPingTimerTask ( ) ; this . heartBeatTimer . scheduleAtFixedRate ( this . hearBeatTaskToRun , 0 , this . heartBeatInterval ) ;


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public boolean addBalancer ( String addr , int sipPort , int httpPort , int rmiPort ) { } }

implementation:
if ( addr == null ) throw new NullPointerException ( "addr cant be null!!!" ) ; InetAddress address = null ; try { address = InetAddress . getByName ( addr ) ; } catch ( UnknownHostException e ) { throw new IllegalArgumentException ( "Something wrong with host creation." , e ) ; } String balancerName = address . getCanonicalHostName ( ) + ":" + rmiPort ; if ( register . get ( balancerName ) != null ) { logger . logInfo ( "Sip balancer " + balancerName + " already present, not added" ) ; return false ; } SipLoadBalancer sipLoadBalancer = new SipLoadBalancer ( this , address , sipPort , httpPort , rmiPort ) ; register . put ( balancerName , sipLoadBalancer ) ; // notify the listeners
for ( LoadBalancerHeartBeatingListener loadBalancerHeartBeatingListener : loadBalancerHeartBeatingListeners ) { loadBalancerHeartBeatingListener . loadBalancerAdded ( sipLoadBalancer ) ; } if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "following balancer name : " + balancerName + "/address:" + addr + " added" ) ; } return true ;


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public boolean addBalancer ( String hostName , int sipPort , int httpPort , int index , int rmiPort ) { } }

implementation: return this . addBalancer ( fetchHostAddress ( hostName , index ) . getHostAddress ( ) , sipPort , httpPort , rmiPort ) ;


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public boolean removeBalancer ( String addr , int sipPort , int httpPort , int rmiPort ) { } }

implementation:
if ( addr == null ) throw new NullPointerException ( "addr cant be null!!!" ) ; InetAddress address = null ; try { address = InetAddress . getByName ( addr ) ; } catch ( UnknownHostException e ) { throw new IllegalArgumentException ( "Something wrong with host creation." , e ) ; } SipLoadBalancer sipLoadBalancer = new SipLoadBalancer ( this , address , sipPort , httpPort , rmiPort ) ; String keyToRemove = null ; Iterator < String > keyIterator = register . keySet ( ) . iterator ( ) ; while ( keyIterator . hasNext ( ) && keyToRemove == null ) { String key = keyIterator . next ( ) ; if ( register . get ( key ) . equals ( sipLoadBalancer ) ) { keyToRemove = key ; } } if ( keyToRemove != null ) { register . remove ( keyToRemove ) ; // notify the listeners
for ( LoadBalancerHeartBeatingListener loadBalancerHeartBeatingListener : loadBalancerHeartBeatingListeners ) { loadBalancerHeartBeatingListener . loadBalancerRemoved ( sipLoadBalancer ) ; } if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "following balancer name : " + keyToRemove + "/address:" + addr + " removed" ) ; } return true ; } return false ;


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * { @ inheritDoc } */
public boolean removeBalancer ( String hostName , int sipPort , int httpPort , int index , int rmiPort ) { } }

implementation: InetAddress [ ] hostAddr = null ; try { hostAddr = InetAddress . getAllByName ( hostName ) ; } catch ( UnknownHostException uhe ) { throw new IllegalArgumentException ( "HostName is not a valid host name or it doesnt exists in DNS" , uhe ) ; } if ( index < 0 || index >= hostAddr . length ) { throw new IllegalArgumentException ( "Index in host address array is wrong, it should be [0]<x<[" + hostAddr . length + "] and it is [" + index + "]" ) ; } InetAddress address = hostAddr [ index ] ; return this . removeBalancer ( address . getHostAddress ( ) , sipPort , httpPort , rmiPort ) ;


signature:
public class LoadBalancerHeartBeatingServiceImpl { /** * Contribution from Naoki Nishihara from OKI for Issue 1806 ( SIP LB can not forward when node is listening on 0.0.0.0)
 * Useful for a multi homed address , tries to reach a given load balancer from the list of ip addresses given in param
 * @ param balancerAddr the load balancer to try to reach
 * @ param info the list of node info from which we try to access the load balancer
 * @ return the list stripped from the nodes not able to reach the load balancer */
protected ArrayList < SIPNode > getReachableSIPNodeInfo ( SipLoadBalancer balancer , ArrayList < SIPNode > info ) { } }

implementation:
InetAddress balancerAddr = balancer . getAddress ( ) ; if ( balancerAddr . isLoopbackAddress ( ) ) { return info ; } ArrayList < SIPNode > rv = new ArrayList < SIPNode > ( ) ; for ( SIPNode node : info ) { if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Checking if " + node + " is reachable" ) ; } try { NetworkInterface ni = NetworkInterface . getByInetAddress ( InetAddress . getByName ( node . getIp ( ) ) ) ; // FIXME How can I determine the ttl ?
boolean b = balancerAddr . isReachable ( ni , 5 , 900 ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( node + " is reachable ? " + b ) ; } if ( b ) { if ( balancer . getCustomInfo ( ) != null && ! balancer . getCustomInfo ( ) . isEmpty ( ) ) { for ( Entry < Object , Object > entry : balancer . getCustomInfo ( ) . entrySet ( ) ) { if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "Adding custom info with key " + ( String ) entry . getKey ( ) + " and value " + ( String ) entry . getValue ( ) ) ; } node . getProperties ( ) . put ( ( String ) entry . getKey ( ) , ( String ) entry . getValue ( ) ) ; } } rv . add ( node ) ; } } catch ( IOException e ) { logger . logError ( "IOException" , e ) ; } } if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]" ) ; } return rv ;


signature:
public class LDIFFormatWriter { /** * Write the LDAP entry to the underlying output stream in LDIF format .
 * @ param entry The directory entry .
 * @ throws IOException If there was a problem writing to the underlying output stream . */
public void printEntry ( final Entry entry ) throws IOException { } }

implementation: if ( entry != null ) { final ByteStringBuffer buffer = new ByteStringBuffer ( ) ; entry . toLDIF ( buffer , 77 ) ; if ( ! first ) { ldifOutputStream . write ( eol ) ; } else { first = false ; } ldifOutputStream . write ( buffer . toByteArray ( ) ) ; }


signature:
public class AbstractFormatHandler { /** * Reads directory entries from the input stream and loads them in the LDAP directory server .
 * @ param connection The connection to the LDAP directory server .
 * @ param inputStream The input stream from which directory entries will be read .
 * @ param ignoreErrors If { @ code true } then loading will continue if an error occurs .
 * @ param logger Used to log information or error messages . */
public final void load ( final LDAPInterface connection , final InputStream inputStream , final boolean ignoreErrors , final FormatLogger logger ) { } }

implementation: final FormatReader reader = openReader ( inputStream , logger ) ; if ( reader != null ) { try { boolean keepReading = true ; do { try { final LDIFChangeRecord record = reader . nextRecord ( ) ; if ( record == null ) { keepReading = false ; } else { record . processChange ( connection ) ; } } catch ( final LDIFException e ) { if ( ! ignoreErrors || ! e . mayContinueReading ( ) ) { logger . logError ( "Error parsing directory entry read from the input stream" , e ) ; keepReading = false ; } } catch ( final LDAPException e ) { if ( ! ignoreErrors ) { logger . logError ( "Error loading directory entry into the LDAP directory server" , e ) ; keepReading = false ; } } } while ( keepReading ) ; } catch ( final IOException e ) { logger . logError ( "I/O error reading directory entry from input stream" , e ) ; } finally { try { reader . close ( ) ; } catch ( final IOException e ) { logger . logError ( "I/O error closing the input stream reader" , e ) ; } } }


signature:
public class AbstractFormatHandler { /** * Dump the results of a search against the LDAP directory server to an output stream .
 * @ param connection The connection to the LDAP directory server .
 * @ param base The base DN from which to start the search .
 * @ param filter Query used to filter the directory entries .
 * @ param outputStream The output stream to which the directory entries are to be written .
 * @ param logger Used to log information or error messages . */
public final void dump ( final LDAPInterface connection , final String base , final String filter , final OutputStream outputStream , final FormatLogger logger ) { } }

implementation: final FormatWriter ldapWriter = createWriter ( outputStream , logger ) ; if ( ldapWriter == null ) { logger . logError ( "Error creating writer for output stream" ) ; } else { try { try { final SearchRequest request = new SearchRequest ( base , SearchScope . SUB , Filter . create ( filter ) ) ; final SearchResult result = connection . search ( request ) ; if ( result . getResultCode ( ) == ResultCode . SUCCESS ) { final List < SearchResultEntry > entries = result . getSearchEntries ( ) ; if ( entries != null ) { for ( final SearchResultEntry entry : entries ) { ldapWriter . printEntry ( entry ) ; } } else { logger . logInfo ( "Search did not return any directory entries" ) ; } } else { logger . logError ( "Search operation failed" ) ; } } catch ( final LDAPException e ) { logger . logError ( "Error searching the LDAP directory" , e ) ; } finally { ldapWriter . close ( ) ; } } catch ( final IOException e ) { logger . logError ( "Error writing directory entry to the output stream" , e ) ; } }


signature:
public class DumpMojo { /** * Execute the plugin goal by dumping the matching directory entries to a file in the specified format .
 * @ throws MojoExecutionException If something unexpected happens . */
public final void execute ( ) throws MojoExecutionException { } }

implementation: final File outputFile = new File ( outputDirectory , filename ) ; if ( outputDirectory . exists ( ) || outputDirectory . mkdirs ( ) ) { try { final OutputStream outputStream = new FileOutputStream ( outputFile ) ; try { final LDAPConnection connection = connect ( ) ; try { final FormatHandler handler = getFormatHandler ( ) ; if ( handler != null ) { handler . dump ( connection , searchBase , searchFilter , outputStream , this ) ; } } finally { connection . close ( ) ; } } finally { try { outputStream . close ( ) ; } catch ( final IOException e ) { } } } catch ( final FileNotFoundException e ) { } }


signature:
public class AbstractSource { /** * Open the resource or file and return the input stream . If the path is prefixed with classpath : then it is treated
 * as a classpath resource . Otherwise , it is assumed to be a file system path .
 * @ return The input stream or { @ code null } if the file or resource cannot be found . */
public InputStream open ( ) { } }

implementation: if ( path . startsWith ( CLASSPATH_PREFIX ) ) { final ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; return loader . getResourceAsStream ( path . substring ( CLASSPATH_PREFIX_LENGTH ) ) ; } else { final File file = new File ( path ) ; try { return new FileInputStream ( file ) ; } catch ( final FileNotFoundException e ) { return null ; } }


signature:
public class AbstractLDAPMojo { /** * Connect to the LDAP directory server . The connection attempt will be retried { @ link # connectionRetries } times
 * and the connection time is set to { @ link # connectionTimeout } .
 * @ return The connection object .
 * @ throws MojoExecutionException If the connection to the LDAP directory server failed . */
protected final LDAPConnection connect ( ) throws MojoExecutionException { } }

implementation: final LDAPConnection connection = new LDAPConnection ( ) ; int i = 0 ; while ( i < connectionRetries ) { long start = System . currentTimeMillis ( ) ; try { this . getLog ( ) . info ( "Attempting to connect ot LDAP directory server (" + host + ":" + port + ")" ) ; connection . connect ( host , port , connectionTimeout ) ; break ; } catch ( final LDAPException e ) { final String message = "Could not connect to LDAP directory server (" + host + ":" + port + ")" ; this . getLog ( ) . error ( message , e ) ; if ( i ++ < connectionRetries ) { long time = System . currentTimeMillis ( ) - start ; if ( time < connectionTimeout ) { try { Thread . sleep ( connectionTimeout - time ) ; } catch ( final InterruptedException e1 ) { throw new MojoExecutionException ( message , e1 ) ; } } } else { throw new MojoExecutionException ( message , e ) ; } } } try { connection . bind ( authDn , passwd ) ; } catch ( final LDAPException e ) { throw new MojoExecutionException ( "Could not bind to LDAP directory server as " + authDn , e ) ; } return connection ;


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Configure the Mojo by adding the dependencies for the LDAP server type to the class loader .
 * @ param component The Mojo being configured .
 * @ param configuration The plugin configuration .
 * @ param expressionEvaluator Used to evaluate expressions .
 * @ param containerRealm Used to build the class loader .
 * @ param listener Receives notification when configuration is changed .
 * @ throws ComponentConfigurationException If there was a problem resolving or locating any of the dependencies . */
@ Override public void configureComponent ( final Object component , final PlexusConfiguration configuration , final ExpressionEvaluator expressionEvaluator , final ClassRealm containerRealm , final ConfigurationListener listener ) throws ComponentConfigurationException { } }

implementation: final String serverType = getServerType ( configuration ) ; if ( ! serverType . startsWith ( "dependency-" ) ) { addServerDependenciesToClassRealm ( serverType , expressionEvaluator , containerRealm ) ; } converterLookup . registerConverter ( new ClassRealmConverter ( containerRealm ) ) ; final ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter ( ) ; converter . processConfiguration ( converterLookup , component , containerRealm , configuration , expressionEvaluator , listener ) ;


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Resolve the dependencies for an LDAP server type and add them to the class loader .
 * @ param serverType The LDAP server type .
 * @ param expressionEvaluator Used to evaluate expressions .
 * @ param containerRealm The class loader .
 * @ throws ComponentConfigurationException If there was a problem resolving or locating any of the dependencies . */
private void addServerDependenciesToClassRealm ( final String serverType , final ExpressionEvaluator expressionEvaluator , final ClassRealm containerRealm ) throws ComponentConfigurationException { } }

implementation: final Collection < Artifact > classpathElements = getServerDependencies ( serverType , expressionEvaluator ) ; if ( classpathElements != null ) { for ( final URL url : buildURLs ( classpathElements ) ) { containerRealm . addURL ( url ) ; } }


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Retrive the URLs used to locate the JAR files for a list of artifacts .
 * @ param classpathElements The list of artifacts .
 * @ return The list of URLs .
 * @ throws ComponentConfigurationException If any JAR files could not be located . */
private List < URL > buildURLs ( final Collection < Artifact > classpathElements ) throws ComponentConfigurationException { } }

implementation: final List < URL > urls = new ArrayList < URL > ( classpathElements . size ( ) ) ; for ( final Artifact classpathElement : classpathElements ) { try { final URL url = classpathElement . getFile ( ) . toURI ( ) . toURL ( ) ; urls . add ( url ) ; } catch ( final MalformedURLException e ) { throw new ComponentConfigurationException ( "Unable to access project dependency: " + classpathElement , e ) ; } } return urls ;


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Resolve the LDAP server type artifact and its dependencies .
 * @ param serverType The LDAP server type .
 * @ param expressionEvaluator Used to get the Maven project model and repository session objects .
 * @ return A list of dependencies required for the LDAP server type .
 * @ throws ComponentConfigurationException If the was a problem resolving the dependencies for
 * the LDAP server type . */
private Collection < Artifact > getServerDependencies ( final String serverType , final ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException { } }

implementation: try { final MavenProject project = ( MavenProject ) expressionEvaluator . evaluate ( "${project}" ) ; final String localRepo = ( String ) expressionEvaluator . evaluate ( "${settings.localRepository}" ) ; final ArtifactRepository localRepository = repositorySystem . createLocalRepository ( new File ( localRepo ) ) ; final RepositoryRequest repositoryRequest = new DefaultRepositoryRequest ( ) ; repositoryRequest . setRemoteRepositories ( project . getRemoteArtifactRepositories ( ) ) ; repositoryRequest . setLocalRepository ( localRepository ) ; final ArtifactResolutionRequest request = new ArtifactResolutionRequest ( repositoryRequest ) ; request . setArtifact ( getServerArtifact ( serverType ) ) ; request . setResolveTransitively ( true ) ; final ArtifactResolutionResult result = repositorySystem . resolve ( request ) ; if ( result . isSuccess ( ) ) { return result . getArtifacts ( ) ; } boolean first = true ; final StringBuilder builder = new StringBuilder ( "Cannot resolve dependencies: [" ) ; for ( final Artifact artifact : result . getMissingArtifacts ( ) ) { if ( ! first ) { builder . append ( ',' ) ; } else { first = false ; } builder . append ( artifact . getGroupId ( ) ) ; builder . append ( ':' ) ; builder . append ( artifact . getArtifactId ( ) ) ; builder . append ( ':' ) ; builder . append ( artifact . getVersion ( ) ) ; } builder . append ( "]" ) ; throw new ComponentConfigurationException ( builder . toString ( ) ) ; } catch ( final ExpressionEvaluationException e ) { throw new ComponentConfigurationException ( "Error evaluating expression" , e ) ; } catch ( final InvalidRepositoryException e ) { throw new ComponentConfigurationException ( "Error resolving local repository" , e ) ; }


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Get the artifact descriptor for the JAR file that implements support for the LDAP server type .
 * @ param serverType The LDAP server type .
 * @ return The JAR file artifact descriptor . */
private Artifact getServerArtifact ( final String serverType ) throws ComponentConfigurationException { } }

implementation: if ( serverType . startsWith ( "gav-" ) ) { int index = serverType . indexOf ( "-" , 4 ) ; if ( index > 0 ) { String [ ] gav = serverType . substring ( index + 1 ) . split ( ":" ) ; if ( gav . length == 3 ) { return repositorySystem . createArtifact ( gav [ 0 ] , gav [ 1 ] , gav [ 2 ] , "runtime" , "jar" ) ; } } throw new ComponentConfigurationException ( "Invalid server type: " + serverType ) ; } else { return repositorySystem . createArtifact ( DEFAULT_GROUP_ID , MessageFormat . format ( DEFAULT_ARTIFACT_ID_FORMAT , serverType ) , getClass ( ) . getPackage ( ) . getImplementationVersion ( ) , "runtime" , "jar" ) ; }


signature:
public class IncludeServerDependenciesComponentConfigurator { /** * Determine the configured LDAP server type . If one has not been configured then
 * return the default .
 * @ param configuration The plugin configuration .
 * @ return The LDAP server type . */
private String getServerType ( final PlexusConfiguration configuration ) { } }

implementation: final Pattern pattern = Pattern . compile ( "\\$\\{[A-Za-z0-9\\._]+\\}" ) ; for ( final PlexusConfiguration cfg : configuration . getChildren ( ) ) { if ( cfg . getName ( ) . equals ( SERVER_TYPE_ATTRIBUTE ) ) { if ( pattern . matcher ( cfg . getValue ( ) ) . matches ( ) ) { return DEFAULT_SERVER_TYPE_VALUE ; } else { return cfg . getValue ( ) ; } } } return DEFAULT_SERVER_TYPE_VALUE ;


signature:
public class DSMLFormatHandler { /** * Create the LDAP writer that will dump LDAP entries to a DSML file .
 * @ param outputStream The target output stream .
 * @ param logger Used to log information or error messages .
 * @ return A { @ link DSMLFormatWriter } object . */
@ Override protected FormatWriter createWriter ( final OutputStream outputStream , final FormatLogger logger ) { } }

implementation: try { return new DSMLFormatWriter ( outputStream ) ; } catch ( final IOException e ) { logger . logError ( "Could not create and intialise the DSML writer" , e ) ; } return null ;


signature:
public class DSMLFormatHandler { /** * Create the LDAP reader that will load LDAP entries from a DSML file .
 * @ param inputStream The file input stream .
 * @ param logger Used to log information or error messages .
 * @ return A { @ link DSMLFormatReader } object . */
@ Override protected FormatReader openReader ( final InputStream inputStream , final FormatLogger logger ) { } }

implementation: try { return new DSMLFormatReader ( inputStream ) ; } catch ( final DocumentException e ) { logger . logError ( "Error parsing DSML file" , e ) ; } catch ( final JaxenException e ) { logger . logError ( "Error processing DSML file" , e ) ; } catch ( final IOException e ) { logger . logError ( "Error reading DSML file" , e ) ; } return null ;


signature:
public class AbstractLDAPServer { /** * Used to configure the root DN of the LDAP directory , the working directory used by the directory service to
 * store the directory data , the LDIF file used to seed the directory or the TCP port number on which the server
 * will listening for LDAP traffic .
 * @ param name The name of the property to configure .
 * @ param value The value of the property being configured .
 * @ param logger Used to log error and information messages . */
@ Override public void configure ( final String name , final Object value , final Logger logger ) { } }

implementation: if ( ROOT . equals ( name ) ) { if ( value instanceof String ) { root = ( String ) value ; logger . logInfo ( "Configured root DN for directory server: " + root ) ; } } else if ( OBJECT_CLASSES . equals ( name ) ) { if ( value instanceof String [ ] ) { objectClasses = ( String [ ] ) value ; logger . logInfo ( "Configured object classes for root DN: " + objectClasses ) ; } } else if ( AUTH_DN . equals ( name ) ) { if ( value instanceof String ) { authDn = ( String ) value ; logger . logInfo ( "Configured admin identity for directory server: " + authDn ) ; } } else if ( PASSWD . equals ( name ) ) { if ( value instanceof String ) { passwd = ( String ) value ; logger . logInfo ( "Configured admin credentials for directory server: " + passwd ) ; } } else if ( WORK_DIR . equals ( name ) ) { if ( value instanceof File ) { workingDirectory = ( File ) value ; logger . logInfo ( "Configured working directory for directory server: " + workingDirectory ) ; } } else if ( LDIF_FILE . equals ( name ) ) { if ( value instanceof File ) { ldifFile = ( File ) value ; logger . logInfo ( "Configured LDIF seed data source for directory server: " + ldifFile ) ; } } else if ( LDAP_PORT . equals ( name ) ) { if ( value instanceof Integer ) { serverPort = ( Integer ) value ; logger . logInfo ( "Configured TCP port for directory server: " + serverPort ) ; } }


signature:
public class UnboundIDServer { /** * Configure and start the embedded UnboundID server creating the root DN and loading the LDIF seed data .
 * @ param logger Used to log informational and error messages . */
@ Override public void start ( final Logger logger ) { } }

implementation: try { logger . logInfo ( "Starting UnboundID server" ) ; final InMemoryListenerConfig listenerConfig = InMemoryListenerConfig . createLDAPConfig ( "default" , getServerPort ( ) ) ; final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig ( new DN ( getRoot ( ) ) ) ; config . setListenerConfigs ( listenerConfig ) ; if ( getAuthDn ( ) != null ) { config . addAdditionalBindCredentials ( getAuthDn ( ) , getPasswd ( ) ) ; } server = new InMemoryDirectoryServer ( config ) ; String [ ] objectClasses = getObjectClasses ( ) ; if ( objectClasses == null ) { objectClasses = DEFAULT_ROOT_OBJECT_CLASSES ; } server . add ( new Entry ( getRoot ( ) , new Attribute ( "objectclass" , objectClasses ) ) ) ; if ( getLdifFile ( ) != null ) { final InputStream in = new FileInputStream ( getLdifFile ( ) ) ; try { final LDIFReader reader = new LDIFReader ( in ) ; server . importFromLDIF ( false , reader ) ; } finally { in . close ( ) ; } } server . startListening ( ) ; logger . logInfo ( "Started UnboundID server" ) ; } catch ( final LDAPException e ) { e . printStackTrace ( ) ; logger . logError ( "Could not launch embedded UnboundID directory server" , e ) ; } catch ( final IOException e ) { e . printStackTrace ( ) ; logger . logError ( "Could not launch embedded UnboundID directory server" , e ) ; }


signature:
public class UnboundIDServer { /** * Shutdown the the embedded UnboundID server .
 * @ param logger Used to log informational and error messages . */
@ Override public void stop ( final Logger logger ) { } }

implementation: logger . logInfo ( "Stopping UnboundID server" ) ; server . shutDown ( true ) ; logger . logInfo ( "Stopped UnboundID server" ) ;


signature:
public class DSMLFormatReader { /** * Read the next change record from the underlying input stream .
 * @ return The next change record or { @ code null } if the end of the input stream has been reached . */
public LDIFChangeRecord nextRecord ( ) { } }

implementation: if ( entryIterator . hasNext ( ) ) { try { final Node entryNode = entryIterator . next ( ) ; final String dn = entryNode . valueOf ( "@dn" ) ; final List < Attribute > attributes = new ArrayList < Attribute > ( ) ; final List < Node > objectClassList = ( List < Node > ) objectClassXPath . selectNodes ( entryNode ) ; final String [ ] objectClasses = new String [ objectClassList . size ( ) ] ; for ( int j = 0 ; j < objectClasses . length ; ++ j ) { objectClasses [ j ] = objectClassList . get ( j ) . getStringValue ( ) ; } attributes . add ( new Attribute ( "objectclass" , objectClasses ) ) ; for ( final Node attributeNode : ( List < Node > ) attrXPath . selectNodes ( entryNode ) ) { final String attributeName = attributeNode . valueOf ( "@name" ) ; final List < Node > attributeValueNodes = ( List < Node > ) attrValueXPath . selectNodes ( attributeNode ) ; switch ( attributeValueNodes . size ( ) ) { case 0 : break ; case 1 : { final String attributeValue = attributeValueNodes . get ( 0 ) . getStringValue ( ) ; attributes . add ( new Attribute ( attributeName , attributeValue ) ) ; break ; } default : { final String [ ] attributeValues = new String [ attributeValueNodes . size ( ) ] ; for ( int j = 0 ; j < attributeValueNodes . size ( ) ; ++ j ) { attributeValues [ j ] = attributeValueNodes . get ( j ) . getStringValue ( ) ; } attributes . add ( new Attribute ( attributeName , attributeValues ) ) ; break ; } } } return new LDIFAddChangeRecord ( dn , attributes ) ; } catch ( final JaxenException e ) { return null ; } } else { return null ; }


signature:
public class DSMLFormatReader { /** * Create a { @ link XPath } for the expression { @ code xpathString } .
 * @ param xpathString The expression .
 * @ return The { @ link XPath } .
 * @ throws JaxenException If there was a problem parsing the { @ code xpathString } expression . */
private XPath createXPath ( final String xpathString ) throws JaxenException { } }

implementation: final XPath xpath = new Dom4jXPath ( xpathString ) ; xpath . setNamespaceContext ( namespaceContext ) ; return xpath ;


signature:
public class LoadMojo { /** * Execute the plugin goal iterating over the list of source files and loading the LDAP directory entries from
 * each file using the appropriate handler .
 * @ throws MojoExecutionException If there was an error executing the plugin goal . */
public void execute ( ) throws MojoExecutionException { } }

implementation: if ( ! isSkip ( ) ) { final LDAPConnection connection = connect ( ) ; try { for ( final Source source : sources ) { try { getLog ( ) . info ( "Processing input source: " + source ) ; final FormatHandler handler = getFormatHandler ( source ) ; if ( handler == null ) { getLog ( ) . warn ( "No handler for input source: " + source ) ; } else { final InputStream inputStream = source . open ( ) ; if ( inputStream == null ) { if ( ! this . continueOnError ) { throw new MojoExecutionException ( "Cannot open source for reading: " + source ) ; } else { getLog ( ) . warn ( "Skipping source that could not be opened for reading: " + source ) ; } } else { try { handler . load ( connection , source . open ( ) , continueOnError , this ) ; } finally { inputStream . close ( ) ; } } } } catch ( final IOException e ) { if ( ! this . continueOnError ) { throw new MojoExecutionException ( "Error closing input source: " + source , e ) ; } else { this . getLog ( ) . warn ( "Ignoring error closing input source: " + source , e ) ; } } } } finally { connection . close ( ) ; } }


signature:
public class LoadMojo { /** * Determine which format handler to use for a source file . If the source file is DSML then { @ link # dsmlFormatHandler }
 * will be used and if it is LDIF then { @ link # ldifFormatHandler } .
 * @ param source Describes the source file .
 * @ return The appropriate format handler or { @ code null } if the source is not supported . */
private FormatHandler getFormatHandler ( final Source source ) { } }

implementation: if ( source instanceof Dsml ) { return dsmlFormatHandler ; } else if ( source instanceof Ldif ) { return ldifFormatHandler ; } else { return null ; }


signature:
public class ApacheDSServer { /** * Configure and start the embedded ApacheDS server creating the root DN and loading the LDIF seed data .
 * @ param logger Used to log informational and error messages . */
@ Override public void start ( final Logger logger ) { } }

implementation:
try { logger . logInfo ( "Starting ApacheDS server" ) ; service = new DefaultDirectoryService ( ) ; final List < Interceptor > list = new ArrayList < Interceptor > ( ) ; list . add ( new NormalizationInterceptor ( ) ) ; list . add ( new AuthenticationInterceptor ( ) ) ; list . add ( new ReferralInterceptor ( ) ) ; // list . add ( new AciAuthorizationInterceptor ( ) ) ;
// list . add ( new DefaultAuthorizationInterceptor ( ) ) ;
list . add ( new ExceptionInterceptor ( ) ) ; // list . add ( new ChangeLogInterceptor ( ) ) ;
list . add ( new OperationalAttributeInterceptor ( ) ) ; // list . add ( new SchemaInterceptor ( ) ) ;
list . add ( new SubentryInterceptor ( ) ) ; // list . add ( new CollectiveAttributeInterceptor ( ) ) ;
// list . add ( new EventInterceptor ( ) ) ;
// list . add ( new TriggerInterceptor ( ) ) ;
// list . add ( new JournalInterceptor ( ) ) ;
service . setInterceptors ( list ) ; service . setWorkingDirectory ( getWorkingDirectory ( ) ) ; final JdbmPartition partition = new JdbmPartition ( ) ; partition . setId ( "rootPartition" ) ; partition . setSuffix ( getRoot ( ) ) ; service . addPartition ( partition ) ; service . setExitVmOnShutdown ( false ) ; service . setShutdownHookEnabled ( false ) ; service . getChangeLog ( ) . setEnabled ( false ) ; service . setDenormalizeOpAttrsEnabled ( true ) ; server = new LdapServer ( ) ; server . setDirectoryService ( service ) ; server . setTransports ( new TcpTransport ( getServerPort ( ) ) ) ; service . startup ( ) ; server . start ( ) ; createRoot ( partition ) ; loadLdifFile ( ) ; logger . logInfo ( "Started ApacheDS server" ) ; } catch ( final Exception e ) { logger . logError ( "Error starting ApacheDS server e" ) ; }


signature:
public class ApacheDSServer { /** * Shutdown the the embedded ApacheDS server .
 * @ param logger Used to log informational and error messages . */
@ Override public void stop ( final Logger logger ) { } }

implementation: try { logger . logInfo ( "Stopping ApacheDS server" ) ; server . stop ( ) ; service . shutdown ( ) ; logger . logInfo ( "Stopped ApacheDS server" ) ; } catch ( final Exception e ) { logger . logError ( "Error stopping ApacheDS server" , e ) ; }


signature:
public class ApacheDSServer { /** * Create the root DN .
 * @ param partition The partition in which to create the root DN .
 * @ throws Exception If there was an error creating the root DN . */
private void createRoot ( final Partition partition ) throws Exception { } }

implementation: try { service . getAdminSession ( ) . lookup ( partition . getSuffixDn ( ) ) ; } catch ( final LdapNameNotFoundException e ) { final LdapDN dn = new LdapDN ( getRoot ( ) ) ; final String dc = getRoot ( ) . substring ( 3 , getRoot ( ) . indexOf ( ',' ) ) ; final ServerEntry entry = service . newEntry ( dn ) ; entry . add ( "objectClass" , "top" , "domain" , "extensibleObject" ) ; entry . add ( "dc" , dc ) ; service . getAdminSession ( ) . add ( entry ) ; }


signature:
public class OpenDJServer { /** * Start the OpenDJ in - memory directory server .
 * @ param logger Used for logging . */
@ Override public void start ( final Logger logger ) { } }

implementation: try { logger . logInfo ( "Starting OpenDJ server" ) ; final MemoryBackend backend ; if ( getLdifFile ( ) == null ) { backend = new MemoryBackend ( ) ; } else { final InputStream inputStream = new FileInputStream ( getLdifFile ( ) ) ; final LDIFEntryReader reader = new LDIFEntryReader ( inputStream ) ; backend = new MemoryBackend ( reader ) ; } final ServerConnectionFactory < LDAPClientContext , Integer > connectionHandler = Connections . newServerConnectionFactory ( backend ) ; final LDAPListenerOptions options = new LDAPListenerOptions ( ) . setBacklog ( 4096 ) ; listener = new LDAPListener ( "localhost" , getServerPort ( ) , connectionHandler , options ) ; logger . logInfo ( "Started OpenDJ server" ) ; } catch ( final IOException e ) { logger . logError ( "Error starting OpenDJ server" , e ) ; }


signature:
public class OpenDJServer { /** * Stop the OpenDJ in - memory directory server .
 * @ param logger User for logging . */
@ Override public void stop ( final Logger logger ) { } }

implementation: logger . logInfo ( "Stopping OpenDJ server" ) ; if ( listener != null ) { listener . close ( ) ; } logger . logInfo ( "Stopped OpenDJ server" ) ;


signature:
public class DSMLFormatWriter { /** * Writes an individual LDAP directory entry to the DSML file .
 * @ param entry The directory entry .
 * @ throws IOException If there was a problem writing to the underlying output stream . */
public void printEntry ( final Entry entry ) throws IOException { } }

implementation: final ByteStringBuffer buffer = new ByteStringBuffer ( ) ; buffer . append ( "\t\t<dsml:entry dn=\"" ) ; buffer . append ( entry . getDN ( ) ) ; buffer . append ( "\">" ) ; buffer . append ( eol ) ; final String [ ] values = entry . getAttributeValues ( "objectclass" ) ; if ( values != null ) { buffer . append ( "\t\t\t<dsml:objectclass>" ) ; buffer . append ( eol ) ; for ( final String value : values ) { buffer . append ( "\t\t\t\t<dsml:oc-value>" ) ; buffer . append ( value ) ; buffer . append ( "</dsml:oc-value>" ) ; buffer . append ( eol ) ; } buffer . append ( "\t\t\t</dsml:objectclass>" ) ; buffer . append ( eol ) ; } for ( final Attribute attribute : entry . getAttributes ( ) ) { final String name = attribute . getName ( ) ; if ( ! name . equals ( "objectclass" ) ) { buffer . append ( "\t\t\t<dsml:attr name=\"" ) ; buffer . append ( name ) ; buffer . append ( "\">" ) ; buffer . append ( eol ) ; for ( final String value : attribute . getValues ( ) ) { buffer . append ( "\t\t\t\t<dsml:value>" ) ; buffer . append ( value ) ; buffer . append ( "</dsml:value>" ) ; buffer . append ( eol ) ; } buffer . append ( "\t\t\t</dsml:attr>" ) ; buffer . append ( eol ) ; } } buffer . append ( "\t\t</dsml:entry>" ) ; buffer . append ( eol ) ; ldifOutputStream . write ( buffer . toByteArray ( ) ) ;


signature:
public class DSMLFormatWriter { /** * Close the { @ link FormatWriter } writing the closing tags .
 * @ throws IOException If there was a problem writing to the underlying output stream . */
public void close ( ) throws IOException { } }

implementation: final ByteStringBuffer buffer = new ByteStringBuffer ( ) ; buffer . append ( "\t</dsml:directory-entries>\n" ) ; buffer . append ( eol ) ; buffer . append ( "</dsml:dsml>" ) ; buffer . append ( eol ) ; ldifOutputStream . write ( buffer . toByteArray ( ) ) ;


signature:
public class RunLDAPMojo { /** * Get the server type .
 * @ return The server type . */
@ Override public String getServerType ( ) { } }

implementation: if ( serverType . startsWith ( "dependency-" ) ) { return serverType . substring ( 11 ) ; } if ( serverType . startsWith ( "gav-" ) ) { int index = serverType . indexOf ( "-" , 4 ) ; if ( index > 0 ) { return serverType . substring ( 4 , index ) ; } } return serverType ;


signature:
public class RunLDAPMojo { /** * Get the embedded LDAP directory server configuration .
 * @ return A { @ link Map } containing the server configuration . */
@ Override public Map < String , Object > getServerConfig ( ) { } }

implementation: final Map < String , Object > config = new HashMap < String , Object > ( ) ; config . put ( LDAPServer . ROOT , rootDn ) ; if ( objectClasses != null ) { config . put ( LDAPServer . OBJECT_CLASSES , objectClasses . split ( "," ) ) ; } config . put ( LDAPServer . WORK_DIR , new File ( outputDirectory , serverType ) ) ; if ( ldifFile != null ) { config . put ( LDAPServer . LDIF_FILE , ldifFile ) ; } config . put ( LDAPServer . LDAP_PORT , ldapPort ) ; config . put ( LDAPServer . AUTH_DN , authDn ) ; config . put ( LDAPServer . PASSWD , passwd ) ; return config ;


signature:
public class KairosDb { /** * Sends a metric to the kairos server .
 * @ param metricBuilder the metricbuilder containing the metrics .
 * @ throws de . uniulm . omi . cloudiator . visor . reporting . ReportingException If the kairos server could
 * not be reached . */
protected void sendMetric ( MetricBuilder metricBuilder ) throws ReportingException { } }

implementation:
try { HttpClient client = new HttpClient ( "http://" + this . server + ":" + this . port ) ; Response response = client . pushMetrics ( metricBuilder ) ; // check if response is ok
if ( response . getStatusCode ( ) / 100 != 2 ) { LOGGER . error ( "Kairos DB reported error. Status code: " + response . getStatusCode ( ) ) ; LOGGER . error ( "Error message: " + response . getErrors ( ) ) ; throw new ReportingException ( ) ; } else { LOGGER . debug ( "Kairos DB returned OK. Status code: " + response . getStatusCode ( ) ) ; } client . shutdown ( ) ; } catch ( MalformedURLException | URISyntaxException e ) { throw new ConfigurationException ( e ) ; } catch ( IOException e ) { LOGGER . error ( "Could not request KairosDB." , e ) ; throw new ReportingException ( e ) ; }


signature:
public class KairosDb { /** * Report method . Converts the given metric to a metric kairos understands and sends them .
 * @ param metric the metric to report .
 * @ throws ReportingException of the metric could not be converted . or sent to kairos . */
@ Override public void report ( Metric metric ) throws ReportingException { } }

implementation: KairosMetricConverter kairosMetricConverter = new KairosMetricConverter ( ) ; try { kairosMetricConverter . add ( metric ) ; } catch ( KairosMetricConversionException e ) { throw new ReportingException ( e ) ; } this . sendMetric ( kairosMetricConverter . convert ( ) ) ;


signature:
public class GeometryReader { /** * Read a geometry from the byte reader
 * @ param reader
 * @ return geometry */
public static Geometry readGeometry ( ByteReader reader ) { } }

implementation: Geometry geometry = readGeometry ( reader , null ) ; return geometry ;


signature:
public class GeometryReader { /** * Read a geometry from the byte reader
 * @ param reader
 * @ param expectedType
 * @ return geometry */
public static < T extends Geometry > T readGeometry ( ByteReader reader , Class < T > expectedType ) { } }

implementation:
ByteOrder originalByteOrder = reader . getByteOrder ( ) ; // Read the byte order and geometry type
GeometryTypeInfo geometryTypeInfo = readGeometryType ( reader ) ; GeometryType geometryType = geometryTypeInfo . getGeometryType ( ) ; boolean hasZ = geometryTypeInfo . hasZ ( ) ; boolean hasM = geometryTypeInfo . hasM ( ) ; Geometry geometry = null ; switch ( geometryType ) { case GEOMETRY : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case POINT : geometry = readPoint ( reader , hasZ , hasM ) ; break ; case LINESTRING : geometry = readLineString ( reader , hasZ , hasM ) ; break ; case POLYGON : geometry = readPolygon ( reader , hasZ , hasM ) ; break ; case MULTIPOINT : geometry = readMultiPoint ( reader , hasZ , hasM ) ; break ; case MULTILINESTRING : geometry = readMultiLineString ( reader , hasZ , hasM ) ; break ; case MULTIPOLYGON : geometry = readMultiPolygon ( reader , hasZ , hasM ) ; break ; case GEOMETRYCOLLECTION : case MULTICURVE : case MULTISURFACE : geometry = readGeometryCollection ( reader , hasZ , hasM ) ; break ; case CIRCULARSTRING : geometry = readCircularString ( reader , hasZ , hasM ) ; break ; case COMPOUNDCURVE : geometry = readCompoundCurve ( reader , hasZ , hasM ) ; break ; case CURVEPOLYGON : geometry = readCurvePolygon ( reader , hasZ , hasM ) ; break ; case CURVE : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case SURFACE : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case POLYHEDRALSURFACE : geometry = readPolyhedralSurface ( reader , hasZ , hasM ) ; break ; case TIN : geometry = readTIN ( reader , hasZ , hasM ) ; break ; case TRIANGLE : geometry = readTriangle ( reader , hasZ , hasM ) ; break ; default : throw new SFException ( "Geometry Type not supported: " + geometryType ) ; } // If there is an expected type , verify the geometry if of that type
if ( expectedType != null && geometry != null && ! expectedType . isAssignableFrom ( geometry . getClass ( ) ) ) { throw new SFException ( "Unexpected Geometry Type. Expected: " + expectedType . getSimpleName ( ) + ", Actual: " + geometry . getClass ( ) . getSimpleName ( ) ) ; } // Restore the byte order
reader . setByteOrder ( originalByteOrder ) ; @ SuppressWarnings ( "unchecked" ) T result = ( T ) geometry ; return result ;


signature:
public class GeometryReader { /** * Read the geometry type info
 * @ param reader
 * byte reader
 * @ return geometry type info */
public static GeometryTypeInfo readGeometryType ( ByteReader reader ) { } }

implementation:
// Read the single byte order byte
byte byteOrderValue = reader . readByte ( ) ; ByteOrder byteOrder = byteOrderValue == 0 ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; reader . setByteOrder ( byteOrder ) ; // Read the geometry type unsigned integer
long unsignedGeometryTypeCode = reader . readUnsignedInt ( ) ; // Check for 2.5D geometry types
boolean hasZ = false ; if ( unsignedGeometryTypeCode > WKB25D ) { hasZ = true ; unsignedGeometryTypeCode -= WKB25D ; } int geometryTypeCode = ( int ) unsignedGeometryTypeCode ; // Determine the geometry type
GeometryType geometryType = GeometryCodes . getGeometryType ( geometryTypeCode ) ; // Determine if the geometry has a z ( 3d ) or m ( linear referencing
// system ) value
if ( ! hasZ ) { hasZ = GeometryCodes . hasZ ( geometryTypeCode ) ; } boolean hasM = GeometryCodes . hasM ( geometryTypeCode ) ; GeometryTypeInfo geometryInfo = new GeometryTypeInfo ( geometryTypeCode , geometryType , hasZ , hasM ) ; return geometryInfo ;


signature:
public class GeometryReader { /** * Read a Point
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return point */
public static Point readPoint ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: double x = reader . readDouble ( ) ; double y = reader . readDouble ( ) ; Point point = new Point ( hasZ , hasM , x , y ) ; if ( hasZ ) { double z = reader . readDouble ( ) ; point . setZ ( z ) ; } if ( hasM ) { double m = reader . readDouble ( ) ; point . setM ( m ) ; } return point ;


signature:
public class GeometryReader { /** * Read a Line String
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return line string */
public static LineString readLineString ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: LineString lineString = new LineString ( hasZ , hasM ) ; int numPoints = reader . readInt ( ) ; for ( int i = 0 ; i < numPoints ; i ++ ) { Point point = readPoint ( reader , hasZ , hasM ) ; lineString . addPoint ( point ) ; } return lineString ;


signature:
public class GeometryReader { /** * Read a Polygon
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return polygon */
public static Polygon readPolygon ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: Polygon polygon = new Polygon ( hasZ , hasM ) ; int numRings = reader . readInt ( ) ; for ( int i = 0 ; i < numRings ; i ++ ) { LineString ring = readLineString ( reader , hasZ , hasM ) ; polygon . addRing ( ring ) ; } return polygon ;


signature:
public class GeometryReader { /** * Read a Multi Point
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return multi point */
public static MultiPoint readMultiPoint ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: MultiPoint multiPoint = new MultiPoint ( hasZ , hasM ) ; int numPoints = reader . readInt ( ) ; for ( int i = 0 ; i < numPoints ; i ++ ) { Point point = readGeometry ( reader , Point . class ) ; multiPoint . addPoint ( point ) ; } return multiPoint ;


signature:
public class GeometryReader { /** * Read a Multi Line String
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return multi line string */
public static MultiLineString readMultiLineString ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: MultiLineString multiLineString = new MultiLineString ( hasZ , hasM ) ; int numLineStrings = reader . readInt ( ) ; for ( int i = 0 ; i < numLineStrings ; i ++ ) { LineString lineString = readGeometry ( reader , LineString . class ) ; multiLineString . addLineString ( lineString ) ; } return multiLineString ;


signature:
public class GeometryReader { /** * Read a Multi Polygon
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return multi polygon */
public static MultiPolygon readMultiPolygon ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: MultiPolygon multiPolygon = new MultiPolygon ( hasZ , hasM ) ; int numPolygons = reader . readInt ( ) ; for ( int i = 0 ; i < numPolygons ; i ++ ) { Polygon polygon = readGeometry ( reader , Polygon . class ) ; multiPolygon . addPolygon ( polygon ) ; } return multiPolygon ;


signature:
public class GeometryReader { /** * Read a Geometry Collection
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return geometry collection */
public static GeometryCollection < Geometry > readGeometryCollection ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: GeometryCollection < Geometry > geometryCollection = new GeometryCollection < Geometry > ( hasZ , hasM ) ; int numGeometries = reader . readInt ( ) ; for ( int i = 0 ; i < numGeometries ; i ++ ) { Geometry geometry = readGeometry ( reader , Geometry . class ) ; geometryCollection . addGeometry ( geometry ) ; } return geometryCollection ;


signature:
public class GeometryReader { /** * Read a Circular String
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return circular string */
public static CircularString readCircularString ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: CircularString circularString = new CircularString ( hasZ , hasM ) ; int numPoints = reader . readInt ( ) ; for ( int i = 0 ; i < numPoints ; i ++ ) { Point point = readPoint ( reader , hasZ , hasM ) ; circularString . addPoint ( point ) ; } return circularString ;


signature:
public class GeometryReader { /** * Read a Compound Curve
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return compound curve */
public static CompoundCurve readCompoundCurve ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: CompoundCurve compoundCurve = new CompoundCurve ( hasZ , hasM ) ; int numLineStrings = reader . readInt ( ) ; for ( int i = 0 ; i < numLineStrings ; i ++ ) { LineString lineString = readGeometry ( reader , LineString . class ) ; compoundCurve . addLineString ( lineString ) ; } return compoundCurve ;