idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
14,900 | String upcaseFirst ( String name ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( name . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) ) ; sb . append ( name . substring ( 1 ) ) ; return sb . toString ( ) ; } | Upcase first letter |
14,901 | public int getInitialSize ( ) { if ( initialSize == null ) return getMinSize ( ) ; if ( initialSize . intValue ( ) > maxSize ) return maxSize ; return initialSize . intValue ( ) ; } | Get initial - pool - size |
14,902 | private String dumpQueuedThread ( Thread t ) { StringBuilder sb = new StringBuilder ( ) ; sb = sb . append ( "Queued thread: " ) ; sb = sb . append ( t . getName ( ) ) ; sb = sb . append ( newLine ) ; StackTraceElement [ ] stes = SecurityActions . getStackTrace ( t ) ; if ( stes != null ) { for ( StackTraceElement ste : stes ) { sb = sb . append ( " " ) ; sb = sb . append ( ste . getClassName ( ) ) ; sb = sb . append ( ":" ) ; sb = sb . append ( ste . getMethodName ( ) ) ; sb = sb . append ( ":" ) ; sb = sb . append ( ste . getLineNumber ( ) ) ; sb = sb . append ( newLine ) ; } } return sb . toString ( ) ; } | Dump a thread |
14,903 | public synchronized void addEvent ( WorkManagerEvent event ) { if ( trace ) log . tracef ( "addEvent(%s)" , event ) ; List < WorkManagerEvent > e = events . get ( event . getAddress ( ) . getWorkManagerName ( ) ) ; if ( e == null ) { e = new ArrayList < WorkManagerEvent > ( ) ; events . put ( event . getAddress ( ) . getWorkManagerName ( ) , e ) ; } e . add ( event ) ; } | Add an event |
14,904 | private ScriptText createScriptText ( int key , BMRule rule ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "# BMUnit autogenerated script: " ) . append ( rule . name ( ) ) ; builder . append ( "\nRULE " ) ; builder . append ( rule . name ( ) ) ; if ( rule . isInterface ( ) ) { builder . append ( "\nINTERFACE " ) ; } else { builder . append ( "\nCLASS " ) ; } builder . append ( rule . targetClass ( ) ) ; builder . append ( "\nMETHOD " ) ; builder . append ( rule . targetMethod ( ) ) ; String location = rule . targetLocation ( ) ; if ( location != null && location . length ( ) > 0 ) { builder . append ( "\nAT " ) ; builder . append ( location ) ; } String binding = rule . binding ( ) ; if ( binding != null && binding . length ( ) > 0 ) { builder . append ( "\nBIND " ) ; builder . append ( binding ) ; } String helper = rule . helper ( ) ; if ( helper != null && helper . length ( ) > 0 ) { builder . append ( "\nHELPER " ) ; builder . append ( helper ) ; } builder . append ( "\nIF " ) ; builder . append ( rule . condition ( ) ) ; builder . append ( "\nDO " ) ; builder . append ( rule . action ( ) ) ; builder . append ( "\nENDRULE\n" ) ; return new ScriptText ( "IronJacamarWithByteman" + key , builder . toString ( ) ) ; } | Create a ScriptText instance |
14,905 | static Class < ? > [ ] getDeclaredClasses ( final Class < ? > c ) { if ( System . getSecurityManager ( ) == null ) return c . getDeclaredClasses ( ) ; return AccessController . doPrivileged ( new PrivilegedAction < Class < ? > [ ] > ( ) { public Class < ? > [ ] run ( ) { return c . getDeclaredClasses ( ) ; } } ) ; } | Get the declared classes |
14,906 | static Field getDeclaredField ( final Class < ? > c , final String name ) throws NoSuchFieldException { if ( System . getSecurityManager ( ) == null ) return c . getDeclaredField ( name ) ; Field result = AccessController . doPrivileged ( new PrivilegedAction < Field > ( ) { public Field run ( ) { try { return c . getDeclaredField ( name ) ; } catch ( NoSuchFieldException e ) { return null ; } } } ) ; if ( result != null ) return result ; throw new NoSuchFieldException ( ) ; } | Get the declared field |
14,907 | public String getAsText ( ) { if ( throwable != null ) return throwable . toString ( ) ; if ( result != null ) { try { if ( editor != null ) { editor . setValue ( result ) ; return editor . getAsText ( ) ; } else { return result . toString ( ) ; } } catch ( Exception e ) { return "String representation of " + name + "unavailable" ; } } return null ; } | Get the text representation |
14,908 | private void checkTransport ( ) throws WorkException { if ( ! transport . isInitialized ( ) ) { try { transport . initialize ( ) ; initialize ( ) ; } catch ( Throwable t ) { WorkException we = new WorkException ( "Exception during transport initialization" ) ; we . initCause ( t ) ; throw we ; } } } | Check the transport |
14,909 | private synchronized void removeDistributedStatistics ( ) { if ( distributedStatistics != null ) { listeners . remove ( ( NotificationListener ) distributedStatistics ) ; distributedStatistics . setTransport ( null ) ; distributedStatistics = null ; } } | Remove distributed statistics |
14,910 | Address getLocalAddress ( ) { if ( localAddress == null ) localAddress = new Address ( getId ( ) , getName ( ) , transport != null ? transport . getId ( ) : null ) ; return localAddress ; } | Get local address |
14,911 | public void setShortRunningThreadPool ( BlockingExecutor executor ) { if ( trace ) log . trace ( "short running executor:" + ( executor != null ? executor . getClass ( ) : "null" ) ) ; if ( executor != null ) { if ( executor instanceof StatisticsExecutor ) { this . shortRunningExecutor = ( StatisticsExecutor ) executor ; } else { this . shortRunningExecutor = new StatisticsExecutorImpl ( executor ) ; } } } | Set the executor for short running tasks |
14,912 | public void setLongRunningThreadPool ( BlockingExecutor executor ) { if ( trace ) log . trace ( "long running executor:" + ( executor != null ? executor . getClass ( ) : "null" ) ) ; if ( executor != null ) { if ( executor instanceof StatisticsExecutor ) { this . longRunningExecutor = ( StatisticsExecutor ) executor ; } else { this . longRunningExecutor = new StatisticsExecutorImpl ( executor ) ; } } } | Set the executor for long running tasks |
14,913 | public void doFirstChecks ( Work work , long startTimeout , ExecutionContext execContext ) throws WorkException { if ( isShutdown ( ) ) throw new WorkRejectedException ( bundle . workmanagerShutdown ( ) ) ; if ( work == null ) throw new WorkRejectedException ( bundle . workIsNull ( ) ) ; if ( startTimeout < 0 ) throw new WorkRejectedException ( bundle . startTimeoutIsNegative ( startTimeout ) ) ; checkAndVerifyWork ( work , execContext ) ; } | Do first checks for work starting methods |
14,914 | void addWorkWrapper ( WorkWrapper ww ) { synchronized ( activeWorkWrappers ) { activeWorkWrappers . add ( ww ) ; if ( statisticsEnabled ) statistics . setWorkActive ( activeWorkWrappers . size ( ) ) ; } } | Add work wrapper to active set |
14,915 | void removeWorkWrapper ( WorkWrapper ww ) { synchronized ( activeWorkWrappers ) { activeWorkWrappers . remove ( ww ) ; if ( statisticsEnabled ) statistics . setWorkActive ( activeWorkWrappers . size ( ) ) ; } } | Remove work wrapper from active set |
14,916 | private BlockingExecutor getExecutor ( Work work ) { BlockingExecutor executor = shortRunningExecutor ; if ( longRunningExecutor != null && WorkManagerUtil . isLongRunning ( work ) ) { executor = longRunningExecutor ; } fireHintsComplete ( work ) ; return executor ; } | Get the executor |
14,917 | private void fireHintsComplete ( Work work ) { if ( work != null && work instanceof WorkContextProvider ) { WorkContextProvider wcProvider = ( WorkContextProvider ) work ; List < WorkContext > contexts = wcProvider . getWorkContexts ( ) ; if ( contexts != null && ! contexts . isEmpty ( ) ) { Iterator < WorkContext > it = contexts . iterator ( ) ; while ( it . hasNext ( ) ) { WorkContext wc = it . next ( ) ; if ( wc instanceof HintsContext ) { HintsContext hc = ( HintsContext ) wc ; if ( hc instanceof WorkContextLifecycleListener ) { WorkContextLifecycleListener listener = ( WorkContextLifecycleListener ) hc ; listener . contextSetupComplete ( ) ; } } } } } } | Fire complete for HintsContext |
14,918 | private void checkAndVerifyWork ( Work work , ExecutionContext executionContext ) throws WorkException { if ( specCompliant ) { verifyWork ( work ) ; } if ( work instanceof WorkContextProvider && executionContext != null ) { throw new WorkRejectedException ( bundle . workExecutionContextMustNullImplementsWorkContextProvider ( ) ) ; } } | Check and verify work before submitting . |
14,919 | private void verifyWork ( Work work ) throws WorkException { Class < ? extends Work > workClass = work . getClass ( ) ; String className = workClass . getName ( ) ; if ( ! validatedWork . contains ( className ) ) { if ( isWorkMethodSynchronized ( workClass , RUN_METHOD_NAME ) ) throw new WorkException ( bundle . runMethodIsSynchronized ( className ) ) ; if ( isWorkMethodSynchronized ( workClass , RELEASE_METHOD_NAME ) ) throw new WorkException ( bundle . releaseMethodIsSynchronized ( className ) ) ; validatedWork . add ( className ) ; } } | Verify the given work instance . |
14,920 | private boolean isWorkMethodSynchronized ( Class < ? extends Work > workClass , String methodName ) { try { Method method = SecurityActions . getMethod ( workClass , methodName , new Class [ 0 ] ) ; if ( Modifier . isSynchronized ( method . getModifiers ( ) ) ) return true ; } catch ( NoSuchMethodException e ) { } return false ; } | Checks if Work implementation class method is synchronized |
14,921 | private void checkWorkCompletionException ( WorkWrapper wrapper ) throws WorkException { if ( wrapper . getWorkException ( ) != null ) { if ( trace ) log . tracef ( "Exception %s for %s" , wrapper . getWorkException ( ) , this ) ; deltaWorkFailed ( ) ; throw wrapper . getWorkException ( ) ; } deltaWorkSuccessful ( ) ; } | Checks work completed status . |
14,922 | private void fireWorkContextSetupFailed ( Object workContext , String errorCode , WorkListener workListener , Work work , WorkException exception ) { if ( workListener != null ) { WorkEvent event = new WorkEvent ( this , WorkEvent . WORK_STARTED , work , null ) ; workListener . workStarted ( event ) ; } if ( workContext instanceof WorkContextLifecycleListener ) { WorkContextLifecycleListener listener = ( WorkContextLifecycleListener ) workContext ; listener . contextSetupFailed ( errorCode ) ; } if ( workListener != null ) { WorkEvent event = new WorkEvent ( this , WorkEvent . WORK_COMPLETED , work , exception ) ; workListener . workCompleted ( event ) ; } } | Calls listener with given error code . |
14,923 | @ SuppressWarnings ( "unchecked" ) private < T extends WorkContext > Class < T > getSupportedWorkContextClass ( Class < T > adaptorWorkContext ) { for ( Class < ? extends WorkContext > supportedWorkContext : SUPPORTED_WORK_CONTEXT_CLASSES ) { if ( supportedWorkContext . isAssignableFrom ( adaptorWorkContext ) ) { Class clz = adaptorWorkContext ; while ( clz != null ) { if ( clz . equals ( supportedWorkContext ) ) { return clz ; } clz = clz . getSuperclass ( ) ; } } } return null ; } | Returns work context class if given work context is supported by server returns null instance otherwise . |
14,924 | public < T > T getWorkContext ( Class < T > workContextClass ) { T instance = null ; if ( workContexts != null && workContexts . containsKey ( workContextClass ) ) { instance = workContextClass . cast ( workContexts . get ( workContextClass ) ) ; } return instance ; } | Returns work context instance . |
14,925 | public void addWorkContext ( Class < ? extends WorkContext > workContextClass , WorkContext workContext ) { if ( workContextClass == null ) { throw new IllegalArgumentException ( "Work context class is null" ) ; } if ( workContext == null ) { throw new IllegalArgumentException ( "Work context is null" ) ; } if ( workContexts == null ) { workContexts = new HashMap < Class < ? extends WorkContext > , WorkContext > ( 1 ) ; } if ( trace ) log . tracef ( "Adding work context %s for %s" , workContextClass , this ) ; workContexts . put ( workContextClass , workContext ) ; } | Adds new work context . |
14,926 | private void fireWorkContextSetupComplete ( Object workContext ) { if ( workContext != null && workContext instanceof WorkContextLifecycleListener ) { if ( trace ) log . tracef ( "WorkContextSetupComplete(%s) for %s" , workContext , this ) ; WorkContextLifecycleListener listener = ( WorkContextLifecycleListener ) workContext ; listener . contextSetupComplete ( ) ; } } | Calls listener after work context is setted up . |
14,927 | private void fireWorkContextSetupFailed ( Object workContext ) { if ( workContext != null && workContext instanceof WorkContextLifecycleListener ) { if ( trace ) log . tracef ( "WorkContextSetupFailed(%s) for %s" , workContext , this ) ; WorkContextLifecycleListener listener = ( WorkContextLifecycleListener ) workContext ; listener . contextSetupFailed ( WorkContextErrorCodes . CONTEXT_SETUP_FAILED ) ; } } | Calls listener if setup failed |
14,928 | @ SuppressWarnings ( "unchecked" ) public void inject ( Object object , String propertyName , Object propertyValue , String propertyType , boolean includeFields ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { if ( object == null ) throw new IllegalArgumentException ( "Object is null" ) ; if ( propertyName == null || propertyName . trim ( ) . equals ( "" ) ) throw new IllegalArgumentException ( "PropertyName is undefined" ) ; String methodName = "set" + propertyName . substring ( 0 , 1 ) . toUpperCase ( Locale . US ) ; if ( propertyName . length ( ) > 1 ) { methodName += propertyName . substring ( 1 ) ; } Method method = findMethod ( object . getClass ( ) , methodName , propertyType ) ; if ( method != null ) { Class < ? > parameterClass = method . getParameterTypes ( ) [ 0 ] ; Object parameterValue = null ; try { parameterValue = getValue ( propertyName , parameterClass , propertyValue , SecurityActions . getClassLoader ( object . getClass ( ) ) ) ; } catch ( Throwable t ) { throw new InvocationTargetException ( t , t . getMessage ( ) ) ; } if ( ! parameterClass . isPrimitive ( ) || parameterValue != null ) method . invoke ( object , new Object [ ] { parameterValue } ) ; } else { if ( ! includeFields ) throw new NoSuchMethodException ( "Method " + methodName + " not found" ) ; Field field = findField ( object . getClass ( ) , propertyName , propertyType ) ; if ( field != null ) { Class < ? > fieldClass = field . getType ( ) ; Object fieldValue = null ; try { fieldValue = getValue ( propertyName , fieldClass , propertyValue , SecurityActions . getClassLoader ( object . getClass ( ) ) ) ; } catch ( Throwable t ) { throw new InvocationTargetException ( t , t . getMessage ( ) ) ; } field . set ( object , fieldValue ) ; } else { throw new NoSuchMethodException ( "Field " + propertyName + " not found" ) ; } } } | Inject a value into an object property |
14,929 | protected String getSubstitutionValue ( String input ) { if ( input == null || input . trim ( ) . equals ( "" ) ) return input ; while ( input . indexOf ( "${" ) != - 1 ) { int from = input . indexOf ( "${" ) ; int to = input . indexOf ( "}" ) ; int dv = input . indexOf ( ":" , from + 2 ) ; if ( dv != - 1 && dv > to ) { dv = - 1 ; } String systemProperty = "" ; String defaultValue = "" ; if ( dv == - 1 ) { String s = input . substring ( from + 2 , to ) ; if ( "/" . equals ( s ) ) { systemProperty = File . separator ; } else if ( ":" . equals ( s ) ) { systemProperty = File . pathSeparator ; } else { systemProperty = SecurityActions . getSystemProperty ( s ) ; } } else { systemProperty = SecurityActions . getSystemProperty ( input . substring ( from + 2 , dv ) ) ; defaultValue = input . substring ( dv + 1 , to ) ; } String prefix = "" ; String postfix = "" ; if ( from != 0 ) { prefix = input . substring ( 0 , from ) ; } if ( to + 1 < input . length ( ) - 1 ) { postfix = input . substring ( to + 1 ) ; } if ( systemProperty != null && ! systemProperty . trim ( ) . equals ( "" ) ) { input = prefix + systemProperty + postfix ; } else if ( ! defaultValue . trim ( ) . equals ( "" ) ) { input = prefix + defaultValue + postfix ; } else { input = prefix + postfix ; } } return input ; } | System property substitution |
14,930 | public static Boolean getShouldDistribute ( DistributableWork work ) { if ( work != null && work instanceof WorkContextProvider ) { List < WorkContext > contexts = ( ( WorkContextProvider ) work ) . getWorkContexts ( ) ; if ( contexts != null ) { for ( WorkContext wc : contexts ) { if ( wc instanceof DistributableContext ) { DistributableContext dc = ( DistributableContext ) wc ; return dc . getDistribute ( ) ; } else if ( wc instanceof HintsContext ) { HintsContext hc = ( HintsContext ) wc ; if ( hc . getHints ( ) . keySet ( ) . contains ( DistributableContext . DISTRIBUTE ) ) { Serializable value = hc . getHints ( ) . get ( DistributableContext . DISTRIBUTE ) ; if ( value != null && value instanceof Boolean ) { return ( Boolean ) value ; } } } } } } return null ; } | Get should distribute override |
14,931 | private Xid convertXid ( Xid xid ) { if ( xid instanceof XidWrapper ) return xid ; else return new XidWrapperImpl ( xid , pad , jndiName ) ; } | Return wrapper for given xid . |
14,932 | private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; validatorFactory = BeanValidationImpl . createValidatorFactory ( ) ; } | Read the object - Nothing is read as the validator factory is transient . A new instance is created |
14,933 | public void setExecutorService ( ExecutorService v ) { if ( v != null ) { executorService = v ; isExternal = true ; } else { executorService = null ; isExternal = false ; } } | Set the executor service |
14,934 | public void registerPool ( ManagedConnectionPool mcp , long mcpInterval ) { try { lock . lock ( ) ; synchronized ( registeredPools ) { registeredPools . put ( new Key ( System . identityHashCode ( mcp ) , System . currentTimeMillis ( ) , mcpInterval ) , mcp ) ; } if ( mcpInterval > 1 && mcpInterval / 2 < interval ) { interval = interval / 2 ; long maybeNext = System . currentTimeMillis ( ) + interval ; if ( next > maybeNext && maybeNext > 0 ) { next = maybeNext ; condition . signal ( ) ; } } } finally { lock . unlock ( ) ; } } | Register pool for idle connection cleanup |
14,935 | public void unregisterPool ( ManagedConnectionPool mcp ) { synchronized ( registeredPools ) { registeredPools . values ( ) . remove ( mcp ) ; if ( registeredPools . isEmpty ( ) ) interval = Long . MAX_VALUE ; } } | Unregister pool instance for idle connection cleanup |
14,936 | public Metadata registerMetadata ( String name , Connector c , File archive ) { Metadata md = new MetadataImpl ( name , c , archive ) ; metadataRepository . registerMetadata ( md ) ; return md ; } | Register a metadata instance with the repository |
14,937 | protected void createResourceAdapter ( DeploymentBuilder builder , String raClz , Collection < org . ironjacamar . common . api . metadata . spec . ConfigProperty > configProperties , Map < String , String > overrides , TransactionSupportEnum transactionSupport , String productName , String productVersion , InboundResourceAdapter ira , CloneableBootstrapContext bootstrapContext ) throws DeployException { try { Class < ? > clz = Class . forName ( raClz , true , builder . getClassLoader ( ) ) ; javax . resource . spi . ResourceAdapter resourceAdapter = ( javax . resource . spi . ResourceAdapter ) clz . newInstance ( ) ; validationObj . add ( new ValidateClass ( Key . RESOURCE_ADAPTER , clz , configProperties ) ) ; Collection < org . ironjacamar . core . api . deploymentrepository . ConfigProperty > dcps = injectConfigProperties ( resourceAdapter , configProperties , overrides , builder . getClassLoader ( ) ) ; org . ironjacamar . core . spi . statistics . StatisticsPlugin statisticsPlugin = null ; if ( resourceAdapter instanceof org . ironjacamar . core . spi . statistics . Statistics ) statisticsPlugin = ( ( org . ironjacamar . core . spi . statistics . Statistics ) resourceAdapter ) . getStatistics ( ) ; TransactionIntegration ti = null ; if ( isXA ( transactionSupport ) ) { ti = transactionIntegration ; } bootstrapContext . setResourceAdapter ( resourceAdapter ) ; builder . resourceAdapter ( new ResourceAdapterImpl ( resourceAdapter , bootstrapContext , dcps , statisticsPlugin , productName , productVersion , createInboundMapping ( ira , builder . getClassLoader ( ) ) , is16 ( builder . getMetadata ( ) ) , beanValidation , builder . getActivation ( ) . getBeanValidationGroups ( ) , ti ) ) ; } catch ( Throwable t ) { throw new DeployException ( bundle . unableToCreateResourceAdapter ( raClz ) , t ) ; } } | Create resource adapter instance |
14,938 | protected void createAdminObject ( DeploymentBuilder builder , Connector connector , AdminObject ao ) throws DeployException { try { String aoClass = findAdminObject ( ao . getClassName ( ) , connector ) ; Class < ? > clz = Class . forName ( aoClass , true , builder . getClassLoader ( ) ) ; Object adminObject = clz . newInstance ( ) ; Collection < org . ironjacamar . common . api . metadata . spec . ConfigProperty > configProperties = findConfigProperties ( aoClass , connector ) ; Collection < org . ironjacamar . core . api . deploymentrepository . ConfigProperty > dcps = injectConfigProperties ( adminObject , configProperties , ao . getConfigProperties ( ) , builder . getClassLoader ( ) ) ; validationObj . add ( new ValidateClass ( Key . ADMIN_OBJECT , clz , configProperties ) ) ; org . ironjacamar . core . spi . statistics . StatisticsPlugin statisticsPlugin = null ; if ( adminObject instanceof org . ironjacamar . core . spi . statistics . Statistics ) statisticsPlugin = ( ( org . ironjacamar . core . spi . statistics . Statistics ) adminObject ) . getStatistics ( ) ; if ( builder . getResourceAdapter ( ) != null ) associateResourceAdapter ( builder . getResourceAdapter ( ) . getResourceAdapter ( ) , adminObject ) ; builder . adminObject ( new AdminObjectImpl ( ao . getJndiName ( ) , adminObject , dcps , ao , statisticsPlugin , jndiStrategy ) ) ; } catch ( Throwable t ) { throw new DeployException ( bundle . unableToCreateAdminObject ( ao . getId ( ) , ao . getJndiName ( ) ) , t ) ; } } | Create admin object instance |
14,939 | private String findManagedConnectionFactory ( String className , Connector connector ) { for ( org . ironjacamar . common . api . metadata . spec . ConnectionDefinition cd : connector . getResourceadapter ( ) . getOutboundResourceadapter ( ) . getConnectionDefinitions ( ) ) { if ( className . equals ( cd . getManagedConnectionFactoryClass ( ) . getValue ( ) ) || className . equals ( cd . getConnectionFactoryInterface ( ) . getValue ( ) ) ) return cd . getManagedConnectionFactoryClass ( ) . getValue ( ) ; } return className ; } | Find the ManagedConnectionFactory class |
14,940 | private String findAdminObject ( String className , Connector connector ) { for ( org . ironjacamar . common . api . metadata . spec . AdminObject ao : connector . getResourceadapter ( ) . getAdminObjects ( ) ) { if ( className . equals ( ao . getAdminobjectClass ( ) . getValue ( ) ) || className . equals ( ao . getAdminobjectInterface ( ) . getValue ( ) ) ) return ao . getAdminobjectClass ( ) . getValue ( ) ; } return className ; } | Find the AdminObject class |
14,941 | private Collection < org . ironjacamar . common . api . metadata . spec . ConfigProperty > findConfigProperties ( String className , Connector connector ) { for ( org . ironjacamar . common . api . metadata . spec . ConnectionDefinition cd : connector . getResourceadapter ( ) . getOutboundResourceadapter ( ) . getConnectionDefinitions ( ) ) { if ( className . equals ( cd . getManagedConnectionFactoryClass ( ) . getValue ( ) ) || className . equals ( cd . getConnectionFactoryInterface ( ) . getValue ( ) ) ) return cd . getConfigProperties ( ) ; } return null ; } | Find the config properties for the class |
14,942 | private Class < ? > convertType ( Class < ? > old ) { if ( Boolean . class . equals ( old ) ) { return boolean . class ; } else if ( boolean . class . equals ( old ) ) { return Boolean . class ; } else if ( Byte . class . equals ( old ) ) { return byte . class ; } else if ( byte . class . equals ( old ) ) { return Byte . class ; } else if ( Short . class . equals ( old ) ) { return short . class ; } else if ( short . class . equals ( old ) ) { return Short . class ; } else if ( Integer . class . equals ( old ) ) { return int . class ; } else if ( int . class . equals ( old ) ) { return Integer . class ; } else if ( Long . class . equals ( old ) ) { return long . class ; } else if ( long . class . equals ( old ) ) { return Long . class ; } else if ( Float . class . equals ( old ) ) { return float . class ; } else if ( float . class . equals ( old ) ) { return Float . class ; } else if ( Double . class . equals ( old ) ) { return double . class ; } else if ( double . class . equals ( old ) ) { return Double . class ; } else if ( Character . class . equals ( old ) ) { return char . class ; } else if ( char . class . equals ( old ) ) { return Character . class ; } return null ; } | Convert type if possible |
14,943 | private boolean isSupported ( Class < ? > t ) { if ( Boolean . class . equals ( t ) || boolean . class . equals ( t ) || Byte . class . equals ( t ) || byte . class . equals ( t ) || Short . class . equals ( t ) || short . class . equals ( t ) || Integer . class . equals ( t ) || int . class . equals ( t ) || Long . class . equals ( t ) || long . class . equals ( t ) || Float . class . equals ( t ) || float . class . equals ( t ) || Double . class . equals ( t ) || double . class . equals ( t ) || Character . class . equals ( t ) || char . class . equals ( t ) || String . class . equals ( t ) ) return true ; return false ; } | Is a support type |
14,944 | @ SuppressWarnings ( "unchecked" ) protected void associateResourceAdapter ( javax . resource . spi . ResourceAdapter resourceAdapter , Object object ) throws DeployException { if ( resourceAdapter != null && object != null && object instanceof ResourceAdapterAssociation ) { try { ResourceAdapterAssociation raa = ( ResourceAdapterAssociation ) object ; raa . setResourceAdapter ( resourceAdapter ) ; } catch ( Throwable t ) { throw new DeployException ( bundle . unableToAssociate ( object . getClass ( ) . getName ( ) ) , t ) ; } } } | Associate resource adapter with the object if it implements ResourceAdapterAssociation |
14,945 | private TransactionSupportEnum getTransactionSupport ( Connector connector , Activation activation ) { if ( activation . getTransactionSupport ( ) != null ) return activation . getTransactionSupport ( ) ; if ( connector . getResourceadapter ( ) . getOutboundResourceadapter ( ) != null ) return connector . getResourceadapter ( ) . getOutboundResourceadapter ( ) . getTransactionSupport ( ) ; return TransactionSupportEnum . XATransaction ; } | Get the transaction support level |
14,946 | private void applyConnectionManagerConfiguration ( ConnectionManagerConfiguration cmc , org . ironjacamar . common . api . metadata . resourceadapter . ConnectionDefinition cd ) { if ( cd . getJndiName ( ) != null ) cmc . setJndiName ( cd . getJndiName ( ) ) ; if ( cd . isSharable ( ) != null ) cmc . setSharable ( cd . isSharable ( ) ) ; if ( cd . isEnlistment ( ) != null ) cmc . setEnlistment ( cd . isEnlistment ( ) ) ; if ( cd . isConnectable ( ) != null ) cmc . setConnectable ( cd . isConnectable ( ) ) ; if ( cd . isTracking ( ) != null ) cmc . setTracking ( cd . isTracking ( ) ) ; } | Apply connection definition to connection manager configuration |
14,947 | private void applyConnectionManagerConfiguration ( ConnectionManagerConfiguration cmc , org . ironjacamar . common . api . metadata . common . Security s ) { if ( s != null && s . getSecurityDomain ( ) != null ) { cmc . setSecurityDomain ( s . getSecurityDomain ( ) ) ; } } | Apply security to connection manager configuration |
14,948 | private void applyConnectionManagerConfiguration ( ConnectionManagerConfiguration cmc , org . ironjacamar . common . api . metadata . common . XaPool xp ) { if ( xp != null ) { if ( xp . isIsSameRmOverride ( ) != null ) cmc . setIsSameRMOverride ( xp . isIsSameRmOverride ( ) ) ; if ( xp . isPadXid ( ) != null ) cmc . setPadXid ( xp . isPadXid ( ) ) ; if ( xp . isWrapXaResource ( ) != null ) cmc . setWrapXAResource ( xp . isWrapXaResource ( ) ) ; } } | Apply xa - pool to connection manager configuration |
14,949 | private void applyConnectionManagerConfiguration ( ConnectionManagerConfiguration cmc , org . ironjacamar . common . api . metadata . common . Timeout t ) { if ( t != null ) { if ( t . getAllocationRetry ( ) != null ) cmc . setAllocationRetry ( t . getAllocationRetry ( ) ) ; if ( t . getAllocationRetryWaitMillis ( ) != null ) cmc . setAllocationRetryWaitMillis ( t . getAllocationRetryWaitMillis ( ) ) ; if ( t . getXaResourceTimeout ( ) != null ) cmc . setXAResourceTimeout ( t . getXaResourceTimeout ( ) ) ; } } | Apply timeout to connection manager configuration |
14,950 | private void applyPoolConfiguration ( PoolConfiguration pc , org . ironjacamar . common . api . metadata . common . Pool p ) { if ( p != null ) { if ( p . getMinPoolSize ( ) != null ) pc . setMinSize ( p . getMinPoolSize ( ) . intValue ( ) ) ; if ( p . getInitialPoolSize ( ) != null ) pc . setInitialSize ( p . getInitialPoolSize ( ) . intValue ( ) ) ; if ( p . getMaxPoolSize ( ) != null ) pc . setMaxSize ( p . getMaxPoolSize ( ) . intValue ( ) ) ; if ( p . isPrefill ( ) != null ) pc . setPrefill ( p . isPrefill ( ) . booleanValue ( ) ) ; if ( p . getFlushStrategy ( ) != null ) pc . setFlushStrategy ( p . getFlushStrategy ( ) ) ; } } | Apply pool to pool configuration |
14,951 | private void applyPoolConfiguration ( PoolConfiguration pc , org . ironjacamar . common . api . metadata . common . Timeout t ) { if ( t != null ) { if ( t . getBlockingTimeoutMillis ( ) != null ) pc . setBlockingTimeout ( t . getBlockingTimeoutMillis ( ) . longValue ( ) ) ; if ( t . getIdleTimeoutMinutes ( ) != null ) pc . setIdleTimeoutMinutes ( t . getIdleTimeoutMinutes ( ) . intValue ( ) ) ; } } | Apply timeout to pool configuration |
14,952 | private void applyPoolConfiguration ( PoolConfiguration pc , org . ironjacamar . common . api . metadata . common . Validation v ) { if ( v != null ) { if ( v . isValidateOnMatch ( ) != null ) pc . setValidateOnMatch ( v . isValidateOnMatch ( ) . booleanValue ( ) ) ; if ( v . isBackgroundValidation ( ) != null ) pc . setBackgroundValidation ( v . isBackgroundValidation ( ) . booleanValue ( ) ) ; if ( v . getBackgroundValidationMillis ( ) != null ) pc . setBackgroundValidationMillis ( v . getBackgroundValidationMillis ( ) . longValue ( ) ) ; if ( v . isUseFastFail ( ) != null ) pc . setUseFastFail ( v . isUseFastFail ( ) . booleanValue ( ) ) ; } } | Apply validation to pool configuration |
14,953 | private Map < String , ActivationSpecImpl > createInboundMapping ( InboundResourceAdapter ira , ClassLoader cl ) throws Exception { if ( ira != null ) { Map < String , ActivationSpecImpl > result = new HashMap < > ( ) ; for ( org . ironjacamar . common . api . metadata . spec . MessageListener ml : ira . getMessageadapter ( ) . getMessagelisteners ( ) ) { String type = ml . getMessagelistenerType ( ) . getValue ( ) ; org . ironjacamar . common . api . metadata . spec . Activationspec as = ml . getActivationspec ( ) ; String clzName = as . getActivationspecClass ( ) . getValue ( ) ; Class < ? > clz = Class . forName ( clzName , true , cl ) ; Map < String , Class < ? > > configProperties = createPropertyMap ( clz ) ; Set < String > requiredConfigProperties = new HashSet < > ( ) ; if ( as . getRequiredConfigProperties ( ) != null ) { for ( org . ironjacamar . common . api . metadata . spec . RequiredConfigProperty rcp : as . getRequiredConfigProperties ( ) ) { requiredConfigProperties . add ( rcp . getConfigPropertyName ( ) . getValue ( ) ) ; } } validationObj . add ( new ValidateClass ( Key . ACTIVATION_SPEC , clz , as . getConfigProperties ( ) ) ) ; ActivationSpecImpl asi = new ActivationSpecImpl ( clzName , configProperties , requiredConfigProperties ) ; if ( ! result . containsKey ( type ) ) result . put ( type , asi ) ; } return result ; } return null ; } | Create an inbound mapping |
14,954 | private Map < String , Class < ? > > createPropertyMap ( Class < ? > clz ) throws Exception { Map < String , Class < ? > > result = new HashMap < > ( ) ; for ( Method m : clz . getMethods ( ) ) { if ( m . getName ( ) . startsWith ( "set" ) ) { if ( m . getReturnType ( ) . equals ( Void . TYPE ) && m . getParameterCount ( ) == 1 && isSupported ( m . getParameterTypes ( ) [ 0 ] ) ) result . put ( m . getName ( ) . substring ( 3 ) , m . getParameterTypes ( ) [ 0 ] ) ; } } return result ; } | Get property map |
14,955 | private String getProductName ( Connector raXml ) { if ( raXml != null && ! XsdString . isNull ( raXml . getEisType ( ) ) ) return raXml . getEisType ( ) . getValue ( ) ; return "" ; } | Get the product name for the resource adapter |
14,956 | private String getProductVersion ( Connector raXml ) { if ( raXml != null && ! XsdString . isNull ( raXml . getResourceadapterVersion ( ) ) ) return raXml . getResourceadapterVersion ( ) . getValue ( ) ; return "" ; } | Get the product version for the resource adapter |
14,957 | private boolean is16 ( Connector connector ) { if ( connector == null || connector . getVersion ( ) == Connector . Version . V_16 || connector . getVersion ( ) == Connector . Version . V_17 ) return true ; return false ; } | Is a 1 . 6 + deployment |
14,958 | @ SuppressWarnings ( "unchecked" ) private void verifyBeanValidation ( Deployment deployment ) throws DeployException { if ( beanValidation != null ) { ValidatorFactory vf = null ; try { vf = beanValidation . getValidatorFactory ( ) ; javax . validation . Validator v = vf . getValidator ( ) ; Collection < String > l = deployment . getActivation ( ) . getBeanValidationGroups ( ) ; if ( l == null || l . isEmpty ( ) ) l = Arrays . asList ( javax . validation . groups . Default . class . getName ( ) ) ; Collection < Class < ? > > groups = new ArrayList < > ( ) ; for ( String clz : l ) { try { groups . add ( Class . forName ( clz , true , deployment . getClassLoader ( ) ) ) ; } catch ( ClassNotFoundException e ) { throw new DeployException ( bundle . unableToLoadBeanValidationGroup ( clz , deployment . getIdentifier ( ) ) , e ) ; } } Set failures = new HashSet ( ) ; if ( deployment . getResourceAdapter ( ) != null ) { Set f = v . validate ( deployment . getResourceAdapter ( ) . getResourceAdapter ( ) , groups . toArray ( new Class < ? > [ groups . size ( ) ] ) ) ; if ( ! f . isEmpty ( ) ) failures . addAll ( f ) ; } if ( deployment . getConnectionFactories ( ) != null ) { for ( org . ironjacamar . core . api . deploymentrepository . ConnectionFactory cf : deployment . getConnectionFactories ( ) ) { Set f = v . validate ( cf . getConnectionFactory ( ) , groups . toArray ( new Class < ? > [ groups . size ( ) ] ) ) ; if ( ! f . isEmpty ( ) ) failures . addAll ( f ) ; } } if ( deployment . getAdminObjects ( ) != null ) { for ( org . ironjacamar . core . api . deploymentrepository . AdminObject ao : deployment . getAdminObjects ( ) ) { Set f = v . validate ( ao . getAdminObject ( ) , groups . toArray ( new Class < ? > [ groups . size ( ) ] ) ) ; if ( ! f . isEmpty ( ) ) failures . addAll ( f ) ; } } if ( ! failures . isEmpty ( ) ) { throw new DeployException ( bundle . violationOfValidationRule ( deployment . getIdentifier ( ) ) , new ConstraintViolationException ( failures ) ) ; } } finally { if ( vf != null ) vf . close ( ) ; } } } | Verify deployment against bean validation |
14,959 | private void loadNativeLibraries ( File root ) { if ( root != null && root . exists ( ) ) { List < String > libs = new ArrayList < String > ( ) ; if ( root . isDirectory ( ) ) { if ( root . listFiles ( ) != null ) { for ( File f : root . listFiles ( ) ) { if ( f . isFile ( ) ) { String fileName = f . getName ( ) . toLowerCase ( Locale . US ) ; if ( fileName . endsWith ( ".a" ) || fileName . endsWith ( ".so" ) || fileName . endsWith ( ".dll" ) ) { libs . add ( f . getAbsolutePath ( ) ) ; } } } } else { log . debugf ( "Root is a directory, but there were an I/O error: %s" , root . getAbsolutePath ( ) ) ; } } if ( libs . size ( ) > 0 ) { for ( String lib : libs ) { try { SecurityActions . load ( lib ) ; log . debugf ( "Loaded library: %s" , lib ) ; } catch ( Throwable t ) { log . debugf ( "Unable to load library: %s" , lib ) ; } } } else { log . debugf ( "No native libraries for %s" , root . getAbsolutePath ( ) ) ; } } } | Load native libraries |
14,960 | protected boolean hasFailuresLevel ( Collection < Failure > failures , int severity ) { if ( failures != null ) { for ( Failure failure : failures ) { if ( failure . getSeverity ( ) == severity ) { return true ; } } } return false ; } | Check for failures at a certain level |
14,961 | public String printFailuresLog ( Validator validator , Collection < Failure > failures , FailureHelper ... fhInput ) { String errorText = "" ; FailureHelper fh = null ; if ( fhInput . length == 0 ) fh = new FailureHelper ( failures ) ; else fh = fhInput [ 0 ] ; if ( failures != null && failures . size ( ) > 0 ) { errorText = fh . asText ( validator . getResourceBundle ( ) ) ; } return errorText ; } | print Failures into Log files . |
14,962 | private void resetXAResourceTimeout ( ) { if ( ! ( xaResource instanceof LocalXAResource ) && xaResourceTimeout > 0 ) { try { xaResource . setTransactionTimeout ( xaResourceTimeout ) ; } catch ( XAException e ) { log . debugf ( e , "Exception during resetXAResourceTimeout for %s" , this ) ; } } } | Reset XAResource timeout |
14,963 | public void process ( Map < String , String > varMap , Writer out ) { try { if ( templateText == null ) { templateText = Utils . readFileIntoString ( input ) ; } String replacedString = replace ( varMap ) ; out . write ( replacedString ) ; out . flush ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Processes the template |
14,964 | public String replace ( Map < String , String > varMap ) { StringBuilder newString = new StringBuilder ( ) ; int p = 0 ; int p0 = 0 ; while ( true ) { p = templateText . indexOf ( "${" , p ) ; if ( p == - 1 ) { newString . append ( templateText . substring ( p0 , templateText . length ( ) ) ) ; break ; } else { newString . append ( templateText . substring ( p0 , p ) ) ; } p0 = p ; p = templateText . indexOf ( "}" , p ) ; if ( p != - 1 ) { String varName = templateText . substring ( p0 + 2 , p ) . trim ( ) ; if ( varMap . containsKey ( varName ) ) { newString . append ( varMap . get ( varName ) ) ; p0 = p + 1 ; } } } return newString . toString ( ) ; } | Replace string in the template text |
14,965 | public Collection < ConnectionFactory > getConnectionFactories ( ) { if ( connectionFactories == null ) return Collections . emptyList ( ) ; return Collections . unmodifiableCollection ( connectionFactories ) ; } | Get connection factories |
14,966 | public DeploymentBuilder connectionFactory ( ConnectionFactory v ) { if ( connectionFactories == null ) connectionFactories = new ArrayList < ConnectionFactory > ( ) ; connectionFactories . add ( v ) ; return this ; } | Add connection factory |
14,967 | public Collection < AdminObject > getAdminObjects ( ) { if ( adminObjects == null ) return Collections . emptyList ( ) ; return Collections . unmodifiableCollection ( adminObjects ) ; } | Get admin objects |
14,968 | public DeploymentBuilder adminObject ( AdminObject v ) { if ( adminObjects == null ) adminObjects = new ArrayList < AdminObject > ( ) ; adminObjects . add ( v ) ; return this ; } | Add admin object |
14,969 | protected Boolean attributeAsBoolean ( XMLStreamReader reader , String attributeName , Boolean defaultValue , Map < String , String > expressions ) throws XMLStreamException , ParserException { String attributeString = rawAttributeText ( reader , attributeName ) ; if ( attributeName != null && expressions != null && attributeString != null && attributeString . indexOf ( "${" ) != - 1 ) expressions . put ( attributeName , attributeString ) ; String stringValue = getSubstitutionValue ( attributeString ) ; if ( StringUtils . isEmpty ( stringValue ) || stringValue . trim ( ) . equalsIgnoreCase ( "true" ) || stringValue . trim ( ) . equalsIgnoreCase ( "false" ) ) { return StringUtils . isEmpty ( stringValue ) ? defaultValue : Boolean . valueOf ( stringValue . trim ( ) ) ; } else { throw new ParserException ( bundle . attributeAsBoolean ( attributeString , reader . getLocalName ( ) ) ) ; } } | convert an xml attribute in boolean value . Empty elements results in default value |
14,970 | private String rawAttributeText ( XMLStreamReader reader , String attributeName ) { String attributeString = reader . getAttributeValue ( "" , attributeName ) ; if ( attributeString == null ) return null ; return attributeString . trim ( ) ; } | Read the raw attribute |
14,971 | protected Integer elementAsInteger ( XMLStreamReader reader , String key , Map < String , String > expressions ) throws XMLStreamException , ParserException { Integer integerValue = null ; String elementtext = rawElementText ( reader ) ; if ( key != null && expressions != null && elementtext != null && elementtext . indexOf ( "${" ) != - 1 ) expressions . put ( key , elementtext ) ; try { integerValue = Integer . valueOf ( getSubstitutionValue ( elementtext ) ) ; } catch ( NumberFormatException nfe ) { throw new ParserException ( bundle . notValidNumber ( elementtext , reader . getLocalName ( ) ) ) ; } return integerValue ; } | convert an xml element in Integer value |
14,972 | protected Long elementAsLong ( XMLStreamReader reader , String key , Map < String , String > expressions ) throws XMLStreamException , ParserException { Long longValue = null ; String elementtext = rawElementText ( reader ) ; if ( key != null && expressions != null && elementtext != null && elementtext . indexOf ( "${" ) != - 1 ) expressions . put ( key , elementtext ) ; try { longValue = Long . valueOf ( getSubstitutionValue ( elementtext ) ) ; } catch ( NumberFormatException nfe ) { throw new ParserException ( bundle . notValidNumber ( elementtext , reader . getLocalName ( ) ) ) ; } return longValue ; } | convert an xml element in Long value |
14,973 | protected FlushStrategy elementAsFlushStrategy ( XMLStreamReader reader , Map < String , String > expressions ) throws XMLStreamException , ParserException { String elementtext = rawElementText ( reader ) ; if ( expressions != null && elementtext != null && elementtext . indexOf ( "${" ) != - 1 ) expressions . put ( CommonXML . ELEMENT_FLUSH_STRATEGY , elementtext ) ; FlushStrategy result = FlushStrategy . forName ( getSubstitutionValue ( elementtext ) ) ; if ( result != FlushStrategy . UNKNOWN ) return result ; throw new ParserException ( bundle . notValidFlushStrategy ( elementtext ) ) ; } | convert an xml element in FlushStrategy value |
14,974 | protected Capacity parseCapacity ( XMLStreamReader reader ) throws XMLStreamException , ParserException , ValidateException { Extension incrementer = null ; Extension decrementer = null ; while ( reader . hasNext ( ) ) { switch ( reader . nextTag ( ) ) { case END_ELEMENT : { switch ( reader . getLocalName ( ) ) { case CommonXML . ELEMENT_CAPACITY : return new CapacityImpl ( incrementer , decrementer ) ; default : break ; } } case START_ELEMENT : { switch ( reader . getLocalName ( ) ) { case CommonXML . ELEMENT_INCREMENTER : { incrementer = parseExtension ( reader , CommonXML . ELEMENT_INCREMENTER ) ; break ; } case CommonXML . ELEMENT_DECREMENTER : { decrementer = parseExtension ( reader , CommonXML . ELEMENT_DECREMENTER ) ; break ; } default : } break ; } default : throw new ParserException ( bundle . unexpectedElement ( reader . getLocalName ( ) ) ) ; } } throw new ParserException ( bundle . unexpectedEndOfDocument ( ) ) ; } | Parse capacity tag |
14,975 | public static List < TraceEvent > filterPoolEvents ( List < TraceEvent > data ) throws Exception { List < TraceEvent > result = new ArrayList < TraceEvent > ( ) ; for ( TraceEvent te : data ) { if ( te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_GET || te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_PREFILL || te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_INCREMENTER || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_RETURN || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_IDLE || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_INVALID || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_FLUSH || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_ERROR || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_PREFILL || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_INCREMENTER || te . getType ( ) == TraceEvent . MANAGED_CONNECTION_POOL_CREATE || te . getType ( ) == TraceEvent . MANAGED_CONNECTION_POOL_DESTROY || te . getType ( ) == TraceEvent . PUSH_CCM_CONTEXT || te . getType ( ) == TraceEvent . POP_CCM_CONTEXT || te . getType ( ) == TraceEvent . REGISTER_CCM_CONNECTION || te . getType ( ) == TraceEvent . UNREGISTER_CCM_CONNECTION || te . getType ( ) == TraceEvent . CCM_USER_TRANSACTION || te . getType ( ) == TraceEvent . UNKNOWN_CCM_CONNECTION || te . getType ( ) == TraceEvent . CLOSE_CCM_CONNECTION || te . getType ( ) == TraceEvent . VERSION ) continue ; result . add ( te ) ; } return result ; } | Filter the pool events |
14,976 | public static Map < String , List < TraceEvent > > filterLifecycleEvents ( List < TraceEvent > data ) throws Exception { Map < String , List < TraceEvent > > result = new TreeMap < String , List < TraceEvent > > ( ) ; for ( TraceEvent te : data ) { if ( te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_GET || te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_PREFILL || te . getType ( ) == TraceEvent . CREATE_CONNECTION_LISTENER_INCREMENTER || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_RETURN || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_IDLE || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_INVALID || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_FLUSH || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_ERROR || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_PREFILL || te . getType ( ) == TraceEvent . DESTROY_CONNECTION_LISTENER_INCREMENTER || te . getType ( ) == TraceEvent . MANAGED_CONNECTION_POOL_CREATE || te . getType ( ) == TraceEvent . MANAGED_CONNECTION_POOL_DESTROY ) { List < TraceEvent > l = result . get ( te . getPool ( ) ) ; if ( l == null ) l = new ArrayList < TraceEvent > ( ) ; l . add ( te ) ; result . put ( te . getPool ( ) , l ) ; } } return result ; } | Filter the lifecycle events |
14,977 | public static List < TraceEvent > filterCCMEvents ( List < TraceEvent > data ) throws Exception { List < TraceEvent > result = new ArrayList < TraceEvent > ( ) ; for ( TraceEvent te : data ) { if ( te . getType ( ) == TraceEvent . PUSH_CCM_CONTEXT || te . getType ( ) == TraceEvent . POP_CCM_CONTEXT ) { result . add ( te ) ; } } return result ; } | Filter the CCM events |
14,978 | public static Map < String , List < TraceEvent > > filterCCMPoolEvents ( List < TraceEvent > data ) throws Exception { Map < String , List < TraceEvent > > result = new TreeMap < String , List < TraceEvent > > ( ) ; for ( TraceEvent te : data ) { if ( te . getType ( ) == TraceEvent . REGISTER_CCM_CONNECTION || te . getType ( ) == TraceEvent . UNREGISTER_CCM_CONNECTION || te . getType ( ) == TraceEvent . CCM_USER_TRANSACTION || te . getType ( ) == TraceEvent . UNKNOWN_CCM_CONNECTION || te . getType ( ) == TraceEvent . CLOSE_CCM_CONNECTION ) { List < TraceEvent > l = result . get ( te . getPool ( ) ) ; if ( l == null ) l = new ArrayList < TraceEvent > ( ) ; l . add ( te ) ; result . put ( te . getPool ( ) , l ) ; } } return result ; } | Filter the CCM pool events |
14,979 | public static Map < String , Set < String > > poolManagedConnectionPools ( List < TraceEvent > data ) throws Exception { Map < String , Set < String > > result = new TreeMap < String , Set < String > > ( ) ; for ( TraceEvent te : data ) { if ( te . getType ( ) == TraceEvent . GET_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . GET_CONNECTION_LISTENER_NEW || te . getType ( ) == TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER_NEW ) { Set < String > s = result . get ( te . getPool ( ) ) ; if ( s == null ) s = new TreeSet < String > ( ) ; s . add ( te . getManagedConnectionPool ( ) ) ; result . put ( te . getPool ( ) , s ) ; } } return result ; } | Pool to Managed Connection Pools mapping |
14,980 | public static List < TraceEvent > getEvents ( FileReader fr , File directory ) throws Exception { return getEvents ( getData ( fr , directory ) ) ; } | Get the events |
14,981 | public static boolean isStartState ( TraceEvent te ) { if ( te . getType ( ) == TraceEvent . GET_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . GET_CONNECTION_LISTENER_NEW || te . getType ( ) == TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER_NEW || te . getType ( ) == TraceEvent . CLEAR_CONNECTION_LISTENER ) return true ; return false ; } | Is start state |
14,982 | public static boolean isEndState ( TraceEvent te ) { if ( te . getType ( ) == TraceEvent . RETURN_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . RETURN_CONNECTION_LISTENER_WITH_KILL || te . getType ( ) == TraceEvent . RETURN_INTERLEAVING_CONNECTION_LISTENER || te . getType ( ) == TraceEvent . RETURN_INTERLEAVING_CONNECTION_LISTENER_WITH_KILL || te . getType ( ) == TraceEvent . CLEAR_CONNECTION_LISTENER ) return true ; return false ; } | Is end state |
14,983 | public static Map < String , List < Interaction > > getConnectionListenerData ( List < Interaction > data ) { Map < String , List < Interaction > > result = new TreeMap < String , List < Interaction > > ( ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { Interaction interaction = data . get ( i ) ; List < Interaction > l = result . get ( interaction . getConnectionListener ( ) ) ; if ( l == null ) l = new ArrayList < Interaction > ( ) ; l . add ( interaction ) ; result . put ( interaction . getConnectionListener ( ) , l ) ; } return result ; } | Get a connection listener map |
14,984 | public static boolean hasException ( List < TraceEvent > events ) { for ( TraceEvent te : events ) { if ( te . getType ( ) == TraceEvent . EXCEPTION ) return true ; } return false ; } | Has an exception event |
14,985 | public static String exceptionDescription ( String encoded ) { char [ ] data = encoded . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { char c = data [ i ] ; if ( c == '|' ) { sb = sb . append ( '\n' ) ; } else if ( c == '/' ) { sb = sb . append ( '\r' ) ; } else if ( c == '\\' ) { sb = sb . append ( '\t' ) ; } else if ( c == '_' ) { sb = sb . append ( ' ' ) ; } else { sb = sb . append ( c ) ; } } return sb . toString ( ) ; } | Get exception description |
14,986 | public static String prettyPrint ( TraceEvent te ) { if ( te . getType ( ) != TraceEvent . GET_CONNECTION_LISTENER && te . getType ( ) != TraceEvent . GET_CONNECTION_LISTENER_NEW && te . getType ( ) != TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER && te . getType ( ) != TraceEvent . GET_INTERLEAVING_CONNECTION_LISTENER_NEW && te . getType ( ) != TraceEvent . RETURN_CONNECTION_LISTENER && te . getType ( ) != TraceEvent . RETURN_CONNECTION_LISTENER_WITH_KILL && te . getType ( ) != TraceEvent . RETURN_INTERLEAVING_CONNECTION_LISTENER && te . getType ( ) != TraceEvent . RETURN_INTERLEAVING_CONNECTION_LISTENER_WITH_KILL && te . getType ( ) != TraceEvent . CREATE_CONNECTION_LISTENER_GET && te . getType ( ) != TraceEvent . CREATE_CONNECTION_LISTENER_PREFILL && te . getType ( ) != TraceEvent . CREATE_CONNECTION_LISTENER_INCREMENTER && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_RETURN && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_IDLE && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_INVALID && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_FLUSH && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_ERROR && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_PREFILL && te . getType ( ) != TraceEvent . DESTROY_CONNECTION_LISTENER_INCREMENTER && te . getType ( ) != TraceEvent . EXCEPTION && te . getType ( ) != TraceEvent . PUSH_CCM_CONTEXT && te . getType ( ) != TraceEvent . POP_CCM_CONTEXT ) return te . toString ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "IJTRACER" ) ; sb . append ( "-" ) ; sb . append ( te . getPool ( ) ) ; sb . append ( "-" ) ; sb . append ( te . getManagedConnectionPool ( ) ) ; sb . append ( "-" ) ; sb . append ( te . getThreadId ( ) ) ; sb . append ( "-" ) ; sb . append ( te . getType ( ) ) ; sb . append ( "-" ) ; sb . append ( te . getTimestamp ( ) ) ; sb . append ( "-" ) ; sb . append ( te . getConnectionListener ( ) ) ; sb . append ( "-" ) ; sb . append ( "DATA" ) ; return sb . toString ( ) ; } | Pretty print event |
14,987 | public static TraceEvent getVersion ( List < TraceEvent > events ) { for ( TraceEvent te : events ) { if ( te . getType ( ) == TraceEvent . VERSION ) return te ; } return null ; } | Get the version |
14,988 | static boolean hasMoreApplicationEvents ( List < TraceEvent > events , int index ) { if ( index < 0 || index >= events . size ( ) ) return false ; for ( int j = index ; j < events . size ( ) ; j ++ ) { TraceEvent te = events . get ( j ) ; if ( te . getType ( ) == TraceEvent . GET_CONNECTION || te . getType ( ) == TraceEvent . RETURN_CONNECTION ) return true ; } return false ; } | Has more application events |
14,989 | private Collection < FrameworkMethod > filterAndSort ( List < FrameworkMethod > fms , boolean isStatic ) throws Exception { SortedMap < Integer , FrameworkMethod > m = new TreeMap < > ( ) ; for ( FrameworkMethod fm : fms ) { SecurityActions . setAccessible ( fm . getMethod ( ) ) ; if ( Modifier . isStatic ( fm . getMethod ( ) . getModifiers ( ) ) == isStatic ) { Deployment deployment = ( Deployment ) fm . getAnnotation ( Deployment . class ) ; int order = deployment . order ( ) ; if ( order <= 0 || m . containsKey ( Integer . valueOf ( order ) ) ) throw new Exception ( "Incorrect order definition '" + order + "' on " + fm . getDeclaringClass ( ) . getName ( ) + "#" + fm . getName ( ) ) ; m . put ( Integer . valueOf ( order ) , fm ) ; } } return m . values ( ) ; } | Filter and sort |
14,990 | private Object [ ] getParameters ( FrameworkMethod fm ) { Method m = fm . getMethod ( ) ; SecurityActions . setAccessible ( m ) ; Class < ? > [ ] parameters = m . getParameterTypes ( ) ; Annotation [ ] [ ] parameterAnnotations = m . getParameterAnnotations ( ) ; Object [ ] result = new Object [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Annotation [ ] parameterAnnotation = parameterAnnotations [ i ] ; boolean inject = false ; String name = null ; for ( int j = 0 ; j < parameterAnnotation . length ; j ++ ) { Annotation a = parameterAnnotation [ j ] ; if ( javax . inject . Inject . class . equals ( a . annotationType ( ) ) ) { inject = true ; } else if ( javax . inject . Named . class . equals ( a . annotationType ( ) ) ) { name = ( ( javax . inject . Named ) a ) . value ( ) ; } } if ( inject ) { result [ i ] = resolveBean ( name != null ? name : parameters [ i ] . getSimpleName ( ) , parameters [ i ] ) ; } else { result [ i ] = null ; } } return result ; } | Get parameter values for a method |
14,991 | private Object resolveBean ( String name , Class < ? > type ) { try { return embedded . lookup ( name , type ) ; } catch ( Throwable t ) { return null ; } } | Resolve a bean |
14,992 | static void setAccessible ( final Method m , final boolean value ) { AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { public Object run ( ) { m . setAccessible ( value ) ; return null ; } } ) ; } | Invoke setAccessible on a method |
14,993 | private void writeVars ( Definition def , Writer out , int indent ) throws IOException { writeWithIndent ( out , indent , "/** JNDI name */\n" ) ; writeWithIndent ( out , indent , "private static final String JNDI_NAME = \"java:/eis/" + def . getDefaultValue ( ) + "\";\n\n" ) ; writeWithIndent ( out , indent , "/** MBeanServer instance */\n" ) ; writeWithIndent ( out , indent , "private MBeanServer mbeanServer;\n\n" ) ; writeWithIndent ( out , indent , "/** Object Name */\n" ) ; writeWithIndent ( out , indent , "private String objectName;\n\n" ) ; writeWithIndent ( out , indent , "/** The actual ObjectName instance */\n" ) ; writeWithIndent ( out , indent , "private ObjectName on;\n\n" ) ; writeWithIndent ( out , indent , "/** Registered */\n" ) ; writeWithIndent ( out , indent , "private boolean registered;\n\n" ) ; } | Output class vars |
14,994 | private void writeMethods ( Definition def , Writer out , int indent ) throws IOException { if ( def . getMcfDefs ( ) . get ( 0 ) . isDefineMethodInConnection ( ) ) { if ( def . getMcfDefs ( ) . get ( 0 ) . getMethods ( ) . size ( ) > 0 ) { for ( MethodForConnection method : def . getMcfDefs ( ) . get ( 0 ) . getMethods ( ) ) { writeMethodSignature ( out , indent , method ) ; writeLeftCurlyBracket ( out , indent ) ; writeIndent ( out , indent + 1 ) ; if ( ! method . getReturnType ( ) . equals ( "void" ) ) { out . write ( "return " ) ; } out . write ( "getConnection()." + method . getMethodName ( ) + "(" ) ; int paramSize = method . getParams ( ) . size ( ) ; for ( int i = 0 ; i < paramSize ; i ++ ) { MethodParam param = method . getParams ( ) . get ( i ) ; out . write ( param . getName ( ) ) ; if ( i + 1 < paramSize ) out . write ( ", " ) ; } out . write ( ");\n" ) ; writeRightCurlyBracket ( out , indent ) ; } } } else { writeSimpleMethodSignature ( out , indent , " * Call me" , "public void callMe()" ) ; writeLeftCurlyBracket ( out , indent ) ; writeWithIndent ( out , indent + 1 , "try" ) ; writeLeftCurlyBracket ( out , indent + 1 ) ; writeWithIndent ( out , indent + 2 , "getConnection().callMe();" ) ; writeRightCurlyBracket ( out , indent + 1 ) ; writeWithIndent ( out , indent + 1 , "catch (Exception e)" ) ; writeLeftCurlyBracket ( out , indent + 1 ) ; writeRightCurlyBracket ( out , indent + 1 ) ; writeRightCurlyBracket ( out , indent ) ; } } | Output defined methods |
14,995 | private void writeGetConnection ( Definition def , Writer out , int indent ) throws IOException { String connInterface = def . getMcfDefs ( ) . get ( 0 ) . getConnInterfaceClass ( ) ; String cfInterface = def . getMcfDefs ( ) . get ( 0 ) . getCfInterfaceClass ( ) ; writeWithIndent ( out , indent , "/**\n" ) ; writeWithIndent ( out , indent , " * GetConnection\n" ) ; writeWithIndent ( out , indent , " * @return " + connInterface ) ; writeEol ( out ) ; writeWithIndent ( out , indent , " */\n" ) ; writeWithIndent ( out , indent , "private " + connInterface + " getConnection() throws Exception" ) ; writeLeftCurlyBracket ( out , indent ) ; writeWithIndent ( out , indent + 1 , "InitialContext context = new InitialContext();\n" ) ; writeIndent ( out , indent + 1 ) ; out . write ( cfInterface + " factory = (" + cfInterface + ")context.lookup(JNDI_NAME);\n" ) ; writeIndent ( out , indent + 1 ) ; out . write ( connInterface + " conn = factory.getConnection();\n" ) ; writeWithIndent ( out , indent + 1 , "if (conn == null)" ) ; writeLeftCurlyBracket ( out , indent + 1 ) ; writeIndent ( out , indent + 2 ) ; out . write ( "throw new RuntimeException(\"No connection\");" ) ; writeRightCurlyBracket ( out , indent + 1 ) ; writeWithIndent ( out , indent + 1 , "return conn;" ) ; writeRightCurlyBracket ( out , indent ) ; } | Output getConnection method |
14,996 | public Timer createTimer ( ) { Timer t = new Timer ( true ) ; if ( timers == null ) timers = new ArrayList < Timer > ( ) ; timers . add ( t ) ; return t ; } | Create a timer |
14,997 | public boolean isContextSupported ( Class < ? extends WorkContext > workContextClass ) { if ( workContextClass == null ) return false ; return supportedContexts . contains ( workContextClass ) ; } | Is the work context supported ? |
14,998 | void writeConfigPropsXml ( List < ConfigPropType > props , Writer out , int indent ) throws IOException { if ( props == null || props . size ( ) == 0 ) return ; for ( ConfigPropType prop : props ) { writeIndent ( out , indent ) ; out . write ( "<config-property>" ) ; writeEol ( out ) ; writeIndent ( out , indent + 1 ) ; out . write ( "<config-property-name>" + prop . getName ( ) + "</config-property-name>" ) ; writeEol ( out ) ; writeIndent ( out , indent + 1 ) ; out . write ( "<config-property-type>java.lang." + prop . getType ( ) + "</config-property-type>" ) ; writeEol ( out ) ; writeIndent ( out , indent + 1 ) ; out . write ( "<config-property-value>" + prop . getValue ( ) + "</config-property-value>" ) ; writeEol ( out ) ; writeIndent ( out , indent ) ; out . write ( "</config-property>" ) ; writeEol ( out ) ; writeEol ( out ) ; } } | Output config props xml part |
14,999 | void writeRequireConfigPropsXml ( List < ConfigPropType > props , Writer out , int indent ) throws IOException { if ( props == null || props . size ( ) == 0 ) return ; for ( ConfigPropType prop : props ) { if ( prop . isRequired ( ) ) { writeIndent ( out , indent ) ; out . write ( "<required-config-property>" ) ; writeEol ( out ) ; writeIndent ( out , indent + 1 ) ; out . write ( "<config-property-name>" + prop . getName ( ) + "</config-property-name>" ) ; writeEol ( out ) ; writeIndent ( out , indent ) ; out . write ( "</required-config-property>" ) ; writeEol ( out ) ; } } writeEol ( out ) ; } | Output required config props xml part |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.