private String parseConnectionAttributes_5_0(final XMLExtendedStreamReader reader,  final ModelNode connectionDefinitionNode)
            throws XMLStreamException {
        String poolName = null;
        String jndiName = null;
        int attributeSize = reader.getAttributeCount();

        for (int i = 0; i < attributeSize; i++) {
            ConnectionDefinition.Attribute attribute = ConnectionDefinition.Attribute.forName(reader.getAttributeLocalName(i));
            String value = reader.getAttributeValue(i);
            switch (attribute) {
                case ENABLED: {
                    ENABLED.parseAndSetParameter(value, connectionDefinitionNode, reader);

                    break;
                }
                case CONNECTABLE: {
                    CONNECTABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);

                    break;
                }
                case TRACKING: {
                    TRACKING.parseAndSetParameter(value, connectionDefinitionNode, reader);

                    break;
                }
                case JNDI_NAME: {
                    jndiName = value;
                    JNDINAME.parseAndSetParameter(jndiName, connectionDefinitionNode, reader);
                    break;
                }
                case POOL_NAME: {
                    poolName = value;
                    break;
                }
                case USE_JAVA_CONTEXT: {
                    USE_JAVA_CONTEXT.parseAndSetParameter(value, connectionDefinitionNode, reader);

                    break;
                }

                case USE_CCM: {
                    USE_CCM.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                }

                case SHARABLE: {
                    SHARABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                }

                case ENLISTMENT: {
                    ENLISTMENT.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                }

                case CLASS_NAME: {
                    CLASS_NAME.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                }
                case MCP: {
                    MCP.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                }
                case ENLISTMENT_TRACE:
                    ENLISTMENT_TRACE.parseAndSetParameter(value, connectionDefinitionNode, reader);
                    break;
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
        if (poolName == null || poolName.trim().equals("")) {
            if (jndiName != null && jndiName.trim().length() != 0) {
                if (jndiName.contains("/")) {
                    poolName = jndiName.substring(jndiName.lastIndexOf("/") + 1);
                } else {
                    poolName = jndiName.substring(jndiName.lastIndexOf(":") + 1);
                }
            } else {
                throw ParseUtils.missingRequired(reader, EnumSet.of(ConnectionDefinition.Attribute.JNDI_NAME));
            }
        }
        return poolName;
    }

private String parseConnectionAttributes_5_0 ( final XMLExtendedStreamReader reader , final ModelNode connectionDefinitionNode ) throws XMLStreamException { String poolName = null ; String jndiName = null ; int attributeSize = reader . getAttributeCount ( ) ; for ( int i = 0 ; i < attributeSize ; i ++ ) { ConnectionDefinition . Attribute attribute = ConnectionDefinition . Attribute . forName ( reader . getAttributeLocalName ( i ) ) ; String value = reader . getAttributeValue ( i ) ; switch ( attribute ) { case ENABLED : { ENABLED . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case CONNECTABLE : { CONNECTABLE . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case TRACKING : { TRACKING . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case JNDI_NAME : { jndiName = value ; JNDINAME . parseAndSetParameter ( jndiName , connectionDefinitionNode , reader ) ; break ; } case POOL_NAME : { poolName = value ; break ; } case USE_JAVA_CONTEXT : { USE_JAVA_CONTEXT . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case USE_CCM : { USE_CCM . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case SHARABLE : { SHARABLE . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case ENLISTMENT : { ENLISTMENT . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case CLASS_NAME : { CLASS_NAME . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case MCP : { MCP . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; } case ENLISTMENT_TRACE : ENLISTMENT_TRACE . parseAndSetParameter ( value , connectionDefinitionNode , reader ) ; break ; default : throw ParseUtils . unexpectedAttribute ( reader , i ) ; } } if ( poolName == null || poolName . trim ( ) . equals ( "" ) ) { if ( jndiName != null && jndiName . trim ( ) . length ( ) != 0 ) { if ( jndiName . contains ( "/" ) ) { poolName = jndiName . substring ( jndiName . lastIndexOf ( "/" ) + 1 ) ; } else { poolName = jndiName . substring ( jndiName . lastIndexOf ( ":" ) + 1 ) ; } } else { throw ParseUtils . missingRequired ( reader , EnumSet . of ( ConnectionDefinition . Attribute . JNDI_NAME ) ) ; } } return poolName ; }

Parses connection attributes for version 5.0
@param reader the xml reader
@param connectionDefinitionNode the connection definition add node
@return the pool name
@throws XMLStreamException

Parses connection attributes for version 5 . 0


public ComponentInstance createInstance(Object instance) {
        BasicComponentInstance obj = constructComponentInstance(new ImmediateManagedReference(instance), true);
        obj.constructionFinished();
        return obj;
    }

public ComponentInstance createInstance ( Object instance ) { BasicComponentInstance obj = constructComponentInstance ( new ImmediateManagedReference ( instance ) , true ) ; obj . constructionFinished ( ) ; return obj ; }

Wraps an existing object instance in a ComponentInstance, and run the post construct interceptor chain on it.

@param instance The instance to wrap
@return The new ComponentInstance

Wraps an existing object instance in a ComponentInstance and run the post construct interceptor chain on it .


protected synchronized VirtualFile getResteasySpringVirtualFile() throws DeploymentUnitProcessingException {
        if(resourceRoot != null) {
            return resourceRoot;
        }
        try {
            Module module = Module.getBootModuleLoader().loadModule(MODULE);
            URL fileUrl = module.getClassLoader().getResource(JAR_LOCATION);

            if (fileUrl == null) {
                throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
            }
            File dir = new File(fileUrl.toURI());
            File file = null;
            for (String jar : dir.list()) {
                if (jar.endsWith(".jar")) {
                    file = new File(dir, jar);
                    break;
                }
            }
            if (file == null) {
                throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
            }
            VirtualFile vf = VFS.getChild(file.toURI());
            final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
            Service<Closeable> mountHandleService = new Service<Closeable>() {
                public void start(StartContext startContext) throws StartException {
                }

                public void stop(StopContext stopContext) {
                    VFSUtils.safeClose(mountHandle);
                }

                public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
                    return mountHandle;
                }
            };
            ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SERVICE_NAME),
                    mountHandleService);
            builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
            resourceRoot = vf;

            return resourceRoot;
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e);
        }
    }

protected synchronized VirtualFile getResteasySpringVirtualFile ( ) throws DeploymentUnitProcessingException { if ( resourceRoot != null ) { return resourceRoot ; } try { Module module = Module . getBootModuleLoader ( ) . loadModule ( MODULE ) ; URL fileUrl = module . getClassLoader ( ) . getResource ( JAR_LOCATION ) ; if ( fileUrl == null ) { throw JaxrsLogger . JAXRS_LOGGER . noSpringIntegrationJar ( ) ; } File dir = new File ( fileUrl . toURI ( ) ) ; File file = null ; for ( String jar : dir . list ( ) ) { if ( jar . endsWith ( ".jar" ) ) { file = new File ( dir , jar ) ; break ; } } if ( file == null ) { throw JaxrsLogger . JAXRS_LOGGER . noSpringIntegrationJar ( ) ; } VirtualFile vf = VFS . getChild ( file . toURI ( ) ) ; final Closeable mountHandle = VFS . mountZip ( file , vf , TempFileProviderService . provider ( ) ) ; Service < Closeable > mountHandleService = new Service < Closeable > ( ) { public void start ( StartContext startContext ) throws StartException { } public void stop ( StopContext stopContext ) { VFSUtils . safeClose ( mountHandle ) ; } public Closeable getValue ( ) throws IllegalStateException , IllegalArgumentException { return mountHandle ; } } ; ServiceBuilder < Closeable > builder = serviceTarget . addService ( ServiceName . JBOSS . append ( SERVICE_NAME ) , mountHandleService ) ; builder . setInitialMode ( ServiceController . Mode . ACTIVE ) . install ( ) ; resourceRoot = vf ; return resourceRoot ; } catch ( Exception e ) { throw new DeploymentUnitProcessingException ( e ) ; } }

Lookup Seam integration resource loader.

@return the Seam integration resource loader
@throws DeploymentUnitProcessingException
for any error

Lookup Seam integration resource loader .


protected static String resolveRuntimeName(final OperationContext context, final PathElement address){
        final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel()
                .get(ModelDescriptionConstants.RUNTIME_NAME);
            return runtimeName.asString();
    }

protected static String resolveRuntimeName ( final OperationContext context , final PathElement address ) { final ModelNode runtimeName = context . readResourceFromRoot ( PathAddress . pathAddress ( address ) , false ) . getModel ( ) . get ( ModelDescriptionConstants . RUNTIME_NAME ) ; return runtimeName . asString ( ) ; }

Resolves runtime name of model resource.
@param context - operation context in which handler is invoked
@param address - deployment address
@return runtime name of module. Value which is returned is never null.

Resolves runtime name of model resource .


private static PersistentResourceXMLDescription.PersistentResourceXMLBuilder listenerBuilder(PersistentResourceDefinition resource) {
        return builder(resource.getPathElement())
                // xsd socket-optionsType
                .addAttributes(
                        ListenerResourceDefinition.RECEIVE_BUFFER,
                        ListenerResourceDefinition.SEND_BUFFER,
                        ListenerResourceDefinition.BACKLOG,
                        ListenerResourceDefinition.KEEP_ALIVE,
                        ListenerResourceDefinition.READ_TIMEOUT,
                        ListenerResourceDefinition.WRITE_TIMEOUT,
                        ListenerResourceDefinition.MAX_CONNECTIONS)
                // xsd listener-type
                .addAttributes(
                        ListenerResourceDefinition.SOCKET_BINDING,
                        ListenerResourceDefinition.WORKER,
                        ListenerResourceDefinition.BUFFER_POOL,
                        ListenerResourceDefinition.ENABLED,
                        ListenerResourceDefinition.RESOLVE_PEER_ADDRESS,
                        ListenerResourceDefinition.MAX_ENTITY_SIZE,
                        ListenerResourceDefinition.BUFFER_PIPELINED_DATA,
                        ListenerResourceDefinition.MAX_HEADER_SIZE,
                        ListenerResourceDefinition.MAX_PARAMETERS,
                        ListenerResourceDefinition.MAX_HEADERS,
                        ListenerResourceDefinition.MAX_COOKIES,
                        ListenerResourceDefinition.ALLOW_ENCODED_SLASH,
                        ListenerResourceDefinition.DECODE_URL,
                        ListenerResourceDefinition.URL_CHARSET,
                        ListenerResourceDefinition.ALWAYS_SET_KEEP_ALIVE,
                        ListenerResourceDefinition.MAX_BUFFERED_REQUEST_SIZE,
                        ListenerResourceDefinition.RECORD_REQUEST_START_TIME,
                        ListenerResourceDefinition.ALLOW_EQUALS_IN_COOKIE_VALUE,
                        ListenerResourceDefinition.NO_REQUEST_TIMEOUT,
                        ListenerResourceDefinition.REQUEST_PARSE_TIMEOUT,
                        ListenerResourceDefinition.DISALLOWED_METHODS,
                        ListenerResourceDefinition.SECURE,
                        ListenerResourceDefinition.RFC6265_COOKIE_VALIDATION,
                        ListenerResourceDefinition.ALLOW_UNESCAPED_CHARACTERS_IN_URL);
    }

private
static
PersistentResourceXMLDescription
.
PersistentResourceXMLBuilder
listenerBuilder
(
PersistentResourceDefinition
resource
)
{
return
builder
(
resource
.
getPathElement
(
)
)
// xsd socket-optionsType
.
addAttributes
(
ListenerResourceDefinition
.
RECEIVE_BUFFER
,
ListenerResourceDefinition
.
SEND_BUFFER
,
ListenerResourceDefinition
.
BACKLOG
,
ListenerResourceDefinition
.
KEEP_ALIVE
,
ListenerResourceDefinition
.
READ_TIMEOUT
,
ListenerResourceDefinition
.
WRITE_TIMEOUT
,
ListenerResourceDefinition
.
MAX_CONNECTIONS
)
// xsd listener-type
.
addAttributes
(
ListenerResourceDefinition
.
SOCKET_BINDING
,
ListenerResourceDefinition
.
WORKER
,
ListenerResourceDefinition
.
BUFFER_POOL
,
ListenerResourceDefinition
.
ENABLED
,
ListenerResourceDefinition
.
RESOLVE_PEER_ADDRESS
,
ListenerResourceDefinition
.
MAX_ENTITY_SIZE
,
ListenerResourceDefinition
.
BUFFER_PIPELINED_DATA
,
ListenerResourceDefinition
.
MAX_HEADER_SIZE
,
ListenerResourceDefinition
.
MAX_PARAMETERS
,
ListenerResourceDefinition
.
MAX_HEADERS
,
ListenerResourceDefinition
.
MAX_COOKIES
,
ListenerResourceDefinition
.
ALLOW_ENCODED_SLASH
,
ListenerResourceDefinition
.
DECODE_URL
,
ListenerResourceDefinition
.
URL_CHARSET
,
ListenerResourceDefinition
.
ALWAYS_SET_KEEP_ALIVE
,
ListenerResourceDefinition
.
MAX_BUFFERED_REQUEST_SIZE
,
ListenerResourceDefinition
.
RECORD_REQUEST_START_TIME
,
ListenerResourceDefinition
.
ALLOW_EQUALS_IN_COOKIE_VALUE
,
ListenerResourceDefinition
.
NO_REQUEST_TIMEOUT
,
ListenerResourceDefinition
.
REQUEST_PARSE_TIMEOUT
,
ListenerResourceDefinition
.
DISALLOWED_METHODS
,
ListenerResourceDefinition
.
SECURE
,
ListenerResourceDefinition
.
RFC6265_COOKIE_VALIDATION
,
ListenerResourceDefinition
.
ALLOW_UNESCAPED_CHARACTERS_IN_URL
)
;
}

Registers attributes common across listener types


public static PrimitiveAnalysis getPrimitiveAnalysis(final Class cls) {
        if (cls == null)
            throw IIOPLogger.ROOT_LOGGER.cannotAnalyzeNullClass();

        if (cls == Void.TYPE)
            return voidAnalysis;
        if (cls == Boolean.TYPE)
            return booleanAnalysis;
        if (cls == Character.TYPE)
            return charAnalysis;
        if (cls == Byte.TYPE)
            return byteAnalysis;
        if (cls == Short.TYPE)
            return shortAnalysis;
        if (cls == Integer.TYPE)
            return intAnalysis;
        if (cls == Long.TYPE)
            return longAnalysis;
        if (cls == Float.TYPE)
            return floatAnalysis;
        if (cls == Double.TYPE)
            return doubleAnalysis;

        throw IIOPLogger.ROOT_LOGGER.notAPrimitive(cls.getName());
    }

public static PrimitiveAnalysis getPrimitiveAnalysis ( final Class cls ) { if ( cls == null ) throw IIOPLogger . ROOT_LOGGER . cannotAnalyzeNullClass ( ) ; if ( cls == Void . TYPE ) return voidAnalysis ; if ( cls == Boolean . TYPE ) return booleanAnalysis ; if ( cls == Character . TYPE ) return charAnalysis ; if ( cls == Byte . TYPE ) return byteAnalysis ; if ( cls == Short . TYPE ) return shortAnalysis ; if ( cls == Integer . TYPE ) return intAnalysis ; if ( cls == Long . TYPE ) return longAnalysis ; if ( cls == Float . TYPE ) return floatAnalysis ; if ( cls == Double . TYPE ) return doubleAnalysis ; throw IIOPLogger . ROOT_LOGGER . notAPrimitive ( cls . getName ( ) ) ; }

Get a singleton instance representing one of the primitive types.

Get a singleton instance representing one of the primitive types .


public void shutdown() {
        int value;
        int oldValue;
        //set the shutdown bit
        do {
            oldValue = invocationCount;
            value = SHUTDOWN_FLAG | oldValue;
            //the component has already been shutdown
            if (oldValue == value) {
                return;
            }
        } while (!updater.compareAndSet(this, oldValue, value));

        synchronized (lock) {
            value = invocationCount;
            while (value != SHUTDOWN_FLAG) {
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                value = invocationCount;
                if((value & SHUTDOWN_FLAG) == 0) {
                    return; //component has been restarted
                }
            }
        }
    }

Upon calling this method the EJB will be set to a shutdown state, and no further invocations will be allowed.
It will then wait for all active invocation to finish and then return.

Upon calling this method the EJB will be set to a shutdown state and no further invocations will be allowed . It will then wait for all active invocation to finish and then return .


public static List<String> getUrlPatterns(final String urlPattern) {
        final List<String> linkedList = new LinkedList<String>();

        linkedList.add(urlPattern);

        return linkedList;
    }

public static List < String > getUrlPatterns ( final String urlPattern ) { final List < String > linkedList = new LinkedList < String > ( ) ; linkedList . add ( urlPattern ) ; return linkedList ; }

Creates URL pattern list from passed string.

@param urlPattern URL pattern
@return list wrapping passed parameter

Creates URL pattern list from passed string .


public static JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD) {
        JBossServletsMetaData servletsMD = jbossWebMD.getServlets();

        if (servletsMD == null) {
            servletsMD = new JBossServletsMetaData();
            jbossWebMD.setServlets(servletsMD);
        }

        return servletsMD;
    }

public static JBossServletsMetaData getServlets ( final JBossWebMetaData jbossWebMD ) { JBossServletsMetaData servletsMD = jbossWebMD . getServlets ( ) ; if ( servletsMD == null ) { servletsMD = new JBossServletsMetaData ( ) ; jbossWebMD . setServlets ( servletsMD ) ; } return servletsMD ; }

Gets servlets meta data from jboss web meta data. If not found it creates new servlets meta data and associates them
with jboss web meta data.

@param jbossWebMD jboss web meta data
@return servlets meta data

Gets servlets meta data from jboss web meta data . If not found it creates new servlets meta data and associates them with jboss web meta data .


public static List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD) {
        List<ServletMappingMetaData> servletMappingsMD = jbossWebMD.getServletMappings();

        if (servletMappingsMD == null) {
            servletMappingsMD = new LinkedList<ServletMappingMetaData>();
            jbossWebMD.setServletMappings(servletMappingsMD);
        }

        return servletMappingsMD;
    }

public static List < ServletMappingMetaData > getServletMappings ( final JBossWebMetaData jbossWebMD ) { List < ServletMappingMetaData > servletMappingsMD = jbossWebMD . getServletMappings ( ) ; if ( servletMappingsMD == null ) { servletMappingsMD = new LinkedList < ServletMappingMetaData > ( ) ; jbossWebMD . setServletMappings ( servletMappingsMD ) ; } return servletMappingsMD ; }

Gets servlet mappings meta data from jboss web meta data. If not found it creates new servlet mappings meta data and
associates them with jboss web meta data.

@param jbossWebMD jboss web meta data
@return servlet mappings meta data

Gets servlet mappings meta data from jboss web meta data . If not found it creates new servlet mappings meta data and associates them with jboss web meta data .


public static List<SecurityConstraintMetaData> getSecurityConstraints(final JBossWebMetaData jbossWebMD) {
        List<SecurityConstraintMetaData> securityConstraintsMD = jbossWebMD.getSecurityConstraints();

        if (securityConstraintsMD == null) {
            securityConstraintsMD = new LinkedList<SecurityConstraintMetaData>();
            jbossWebMD.setSecurityConstraints(securityConstraintsMD);
        }

        return securityConstraintsMD;
    }

public static List < SecurityConstraintMetaData > getSecurityConstraints ( final JBossWebMetaData jbossWebMD ) { List < SecurityConstraintMetaData > securityConstraintsMD = jbossWebMD . getSecurityConstraints ( ) ; if ( securityConstraintsMD == null ) { securityConstraintsMD = new LinkedList < SecurityConstraintMetaData > ( ) ; jbossWebMD . setSecurityConstraints ( securityConstraintsMD ) ; } return securityConstraintsMD ; }

Gets security constraints meta data from jboss web meta data. If not found it creates new security constraints meta data
and associates them with jboss web meta data.

@param jbossWebMD jboss web meta data
@return security constraints meta data

Gets security constraints meta data from jboss web meta data . If not found it creates new security constraints meta data and associates them with jboss web meta data .


public static LoginConfigMetaData getLoginConfig(final JBossWebMetaData jbossWebMD) {
        LoginConfigMetaData loginConfigMD = jbossWebMD.getLoginConfig();

        if (loginConfigMD == null) {
            loginConfigMD = new LoginConfigMetaData();
            jbossWebMD.setLoginConfig(loginConfigMD);
        }

        return loginConfigMD;
    }

public static LoginConfigMetaData getLoginConfig ( final JBossWebMetaData jbossWebMD ) { LoginConfigMetaData loginConfigMD = jbossWebMD . getLoginConfig ( ) ; if ( loginConfigMD == null ) { loginConfigMD = new LoginConfigMetaData ( ) ; jbossWebMD . setLoginConfig ( loginConfigMD ) ; } return loginConfigMD ; }

Gets login config meta data from jboss web meta data. If not found it creates new login config meta data and associates
them with jboss web meta data.

@param jbossWebMD jboss web meta data
@return login config meta data

Gets login config meta data from jboss web meta data . If not found it creates new login config meta data and associates them with jboss web meta data .


public static List<ParamValueMetaData> getContextParams(final JBossWebMetaData jbossWebMD) {
        List<ParamValueMetaData> contextParamsMD = jbossWebMD.getContextParams();

        if (contextParamsMD == null) {
            contextParamsMD = new LinkedList<ParamValueMetaData>();
            jbossWebMD.setContextParams(contextParamsMD);
        }

        return contextParamsMD;
    }

public static List < ParamValueMetaData > getContextParams ( final JBossWebMetaData jbossWebMD ) { List < ParamValueMetaData > contextParamsMD = jbossWebMD . getContextParams ( ) ; if ( contextParamsMD == null ) { contextParamsMD = new LinkedList < ParamValueMetaData > ( ) ; jbossWebMD . setContextParams ( contextParamsMD ) ; } return contextParamsMD ; }

Gets context parameters meta data from jboss web meta data. If not found it creates new context parameters meta data and
associates them with jboss web meta data.

@param jbossWebMD jboss web meta data
@return context parameters meta data

Gets context parameters meta data from jboss web meta data . If not found it creates new context parameters meta data and associates them with jboss web meta data .


public static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraintMD) {
        WebResourceCollectionsMetaData webResourceCollectionsMD = securityConstraintMD.getResourceCollections();

        if (webResourceCollectionsMD == null) {
            webResourceCollectionsMD = new WebResourceCollectionsMetaData();
            securityConstraintMD.setResourceCollections(webResourceCollectionsMD);
        }

        return webResourceCollectionsMD;
    }

public static WebResourceCollectionsMetaData getWebResourceCollections ( final SecurityConstraintMetaData securityConstraintMD ) { WebResourceCollectionsMetaData webResourceCollectionsMD = securityConstraintMD . getResourceCollections ( ) ; if ( webResourceCollectionsMD == null ) { webResourceCollectionsMD = new WebResourceCollectionsMetaData ( ) ; securityConstraintMD . setResourceCollections ( webResourceCollectionsMD ) ; } return webResourceCollectionsMD ; }

Gets web resource collections meta data from security constraint meta data. If not found it creates new web resource
collections meta data and associates them with security constraint meta data.

@param securityConstraintMD security constraint meta data
@return web resource collections meta data

Gets web resource collections meta data from security constraint meta data . If not found it creates new web resource collections meta data and associates them with security constraint meta data .


public static List<ParamValueMetaData> getServletInitParams(final ServletMetaData servletMD) {
        List<ParamValueMetaData> initParamsMD = servletMD.getInitParam();

        if (initParamsMD == null) {
            initParamsMD = new LinkedList<ParamValueMetaData>();
            servletMD.setInitParam(initParamsMD);
        }

        return initParamsMD;
    }

public static List < ParamValueMetaData > getServletInitParams ( final ServletMetaData servletMD ) { List < ParamValueMetaData > initParamsMD = servletMD . getInitParam ( ) ; if ( initParamsMD == null ) { initParamsMD = new LinkedList < ParamValueMetaData > ( ) ; servletMD . setInitParam ( initParamsMD ) ; } return initParamsMD ; }

Gets init parameters meta data from servlet meta data. If not found it creates new init parameters meta data and
associates them with servlet meta data.

@param servletMD servlet meta data
@return init parameters meta data

Gets init parameters meta data from servlet meta data . If not found it creates new init parameters meta data and associates them with servlet meta data .


public static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD) {
        final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();

        securityConstraintsMD.add(securityConstraintMD);

        return securityConstraintMD;
    }

public static SecurityConstraintMetaData newSecurityConstraint ( final List < SecurityConstraintMetaData > securityConstraintsMD ) { final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData ( ) ; securityConstraintsMD . add ( securityConstraintMD ) ; return securityConstraintMD ; }

Creates new security constraint meta data and associates them with security constraints meta data.

@param securityConstraintsMD security constraints meta data
@return new security constraing meta data

Creates new security constraint meta data and associates them with security constraints meta data .


public static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern,
            final boolean securedWsdl, final WebResourceCollectionsMetaData webResourceCollectionsMD) {
        final WebResourceCollectionMetaData webResourceCollectionMD = new WebResourceCollectionMetaData();

        webResourceCollectionMD.setWebResourceName(servletName);
        webResourceCollectionMD.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
        webResourceCollectionMD.setHttpMethods(WebMetaDataHelper.getHttpMethods(securedWsdl));
        webResourceCollectionsMD.add(webResourceCollectionMD);

        return webResourceCollectionMD;
    }

public static WebResourceCollectionMetaData newWebResourceCollection ( final String servletName , final String urlPattern , final boolean securedWsdl , final WebResourceCollectionsMetaData webResourceCollectionsMD ) { final WebResourceCollectionMetaData webResourceCollectionMD = new WebResourceCollectionMetaData ( ) ; webResourceCollectionMD . setWebResourceName ( servletName ) ; webResourceCollectionMD . setUrlPatterns ( WebMetaDataHelper . getUrlPatterns ( urlPattern ) ) ; webResourceCollectionMD . setHttpMethods ( WebMetaDataHelper . getHttpMethods ( securedWsdl ) ) ; webResourceCollectionsMD . add ( webResourceCollectionMD ) ; return webResourceCollectionMD ; }

Creates new web resource collection meta data and associates them with web resource collections meta data.

@param servletName servlet name
@param urlPattern URL pattern
@param securedWsdl whether WSDL access is secured
@param webResourceCollectionsMD web resource collections meta data
@return new web resource collection meta data

Creates new web resource collection meta data and associates them with web resource collections meta data .


public static JBossServletMetaData newServlet(final String servletName, final String servletClass,
            final JBossServletsMetaData servletsMD) {
        final JBossServletMetaData servletMD = new JBossServletMetaData();

        servletMD.setServletName(servletName);
        servletMD.setServletClass(servletClass);
        servletsMD.add(servletMD);

        return servletMD;
    }

public static JBossServletMetaData newServlet ( final String servletName , final String servletClass , final JBossServletsMetaData servletsMD ) { final JBossServletMetaData servletMD = new JBossServletMetaData ( ) ; servletMD . setServletName ( servletName ) ; servletMD . setServletClass ( servletClass ) ; servletsMD . add ( servletMD ) ; return servletMD ; }

Creates new servlet meta data and associates them with servlets meta data.

@param servletName servlet name
@param servletClass servlet class name
@param servletsMD servlets meta data
@return new servlet meta data

Creates new servlet meta data and associates them with servlets meta data .


public static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns,
            final List<ServletMappingMetaData> servletMappingsMD) {
        final ServletMappingMetaData servletMappingMD = new ServletMappingMetaData();

        servletMappingMD.setServletName(servletName);
        servletMappingMD.setUrlPatterns(urlPatterns);
        servletMappingsMD.add(servletMappingMD);

        return servletMappingMD;
    }

public static ServletMappingMetaData newServletMapping ( final String servletName , final List < String > urlPatterns , final List < ServletMappingMetaData > servletMappingsMD ) { final ServletMappingMetaData servletMappingMD = new ServletMappingMetaData ( ) ; servletMappingMD . setServletName ( servletName ) ; servletMappingMD . setUrlPatterns ( urlPatterns ) ; servletMappingsMD . add ( servletMappingMD ) ; return servletMappingMD ; }

Creates new servlet mapping meta data and associates them with servlet mappings meta data.

@param servletName servlet name
@param urlPatterns URL patterns
@param servletMappingsMD servlet mapping meta data
@return new servlet mapping meta data

Creates new servlet mapping meta data and associates them with servlet mappings meta data .


public static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames,
            final SecurityConstraintMetaData securityConstraintMD) {
        final AuthConstraintMetaData authConstraintMD = new AuthConstraintMetaData();

        authConstraintMD.setRoleNames(roleNames);
        securityConstraintMD.setAuthConstraint(authConstraintMD);

        return authConstraintMD;
    }

public static AuthConstraintMetaData newAuthConstraint ( final List < String > roleNames , final SecurityConstraintMetaData securityConstraintMD ) { final AuthConstraintMetaData authConstraintMD = new AuthConstraintMetaData ( ) ; authConstraintMD . setRoleNames ( roleNames ) ; securityConstraintMD . setAuthConstraint ( authConstraintMD ) ; return authConstraintMD ; }

Creates new authentication constraint and associates it with security constraint meta data.

@param roleNames roles
@param securityConstraintMD security constraint meta data
@return new authentication constraint meta data

Creates new authentication constraint and associates it with security constraint meta data .


public static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee,
            final SecurityConstraintMetaData securityConstraintMD) {
        final UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData();
        final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);

        userDataConstraintMD.setTransportGuarantee(transportGuaranteeValue);
        securityConstraintMD.setUserDataConstraint(userDataConstraintMD);

        return userDataConstraintMD;
    }

public static UserDataConstraintMetaData newUserDataConstraint ( final String transportGuarantee , final SecurityConstraintMetaData securityConstraintMD ) { final UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData ( ) ; final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType . valueOf ( transportGuarantee ) ; userDataConstraintMD . setTransportGuarantee ( transportGuaranteeValue ) ; securityConstraintMD . setUserDataConstraint ( userDataConstraintMD ) ; return userDataConstraintMD ; }

Creates new user constraint meta data and associates it with security constraint meta data.

@param transportGuarantee transport guarantee value
@param securityConstraintMD security constraint meta data
@return new user data constraint meta data

Creates new user constraint meta data and associates it with security constraint meta data .


public static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD) {
        final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);

        paramsMD.add(paramValueMD);

        return paramValueMD;
    }

public static ParamValueMetaData newParamValue ( final String key , final String value , final List < ParamValueMetaData > paramsMD ) { final ParamValueMetaData paramValueMD = WebMetaDataHelper . newParamValue ( key , value ) ; paramsMD . add ( paramValueMD ) ; return paramValueMD ; }

Creates new parameter meta data and associates it with parameters meta data.

@param key parameter key
@param value parameter value
@param paramsMD parameters meta data
@return new parameter meta data

Creates new parameter meta data and associates it with parameters meta data .


private static ParamValueMetaData newParamValue(final String key, final String value) {
        final ParamValueMetaData paramMD = new ParamValueMetaData();

        paramMD.setParamName(key);
        paramMD.setParamValue(value);

        return paramMD;
    }

private static ParamValueMetaData newParamValue ( final String key , final String value ) { final ParamValueMetaData paramMD = new ParamValueMetaData ( ) ; paramMD . setParamName ( key ) ; paramMD . setParamValue ( value ) ; return paramMD ; }

Creates new parameter with specified key and value.

@param key the key
@param value the value
@return new parameter

Creates new parameter with specified key and value .


private void registerSessionBeanInterceptors(SessionBeanComponentDescription componentDescription, final DeploymentUnit deploymentUnit) {
        // if it's a SFSB then setup appropriate interceptors
        if (componentDescription.isStateful()) {

            // first setup the post construct and pre destroy component interceptors
            componentDescription.getConfigurators().addFirst(new ComponentConfigurator() {
                @Override
                public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws
                    DeploymentUnitProcessingException {
                    configuration.addPostConstructInterceptor(SFSBPreCreateInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.JPA_SFSB_PRE_CREATE);
                    configuration.addPostConstructInterceptor(SFSBCreateInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.JPA_SFSB_CREATE);
                    configuration.addPreDestroyInterceptor(SFSBDestroyInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.JPA_SFSB_DESTROY);
                    configuration.addComponentInterceptor(SFSBInvocationInterceptor.FACTORY, InterceptorOrder.Component.JPA_SFSB_INTERCEPTOR, false);

                    //we need to serialized the entity manager state
                    configuration.getInterceptorContextKeys().add(SFSBInvocationInterceptor.CONTEXT_KEY);
                }
            });
        }
        // register interceptor on stateful/stateless SB with transactional entity manager.
        if ((componentDescription.isStateful() || componentDescription.isStateless())) {
            componentDescription.getConfigurators().add(new ComponentConfigurator() {
                @Override
                public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws
                    DeploymentUnitProcessingException {
                    configuration.addComponentInterceptor(SBInvocationInterceptor.FACTORY, InterceptorOrder.Component.JPA_SESSION_BEAN_INTERCEPTOR, false);
                }
            });
        }
    }

Register our listeners on SFSB that will be created


protected Class<?> processInjectionTargets(final ResourceInjectionTarget resourceInjectionTarget, InjectionSource injectionSource, ClassLoader classLoader, DeploymentReflectionIndex deploymentReflectionIndex, ResourceInjectionMetaData entry, Class<?> classType) throws DeploymentUnitProcessingException {
        if (entry.getInjectionTargets() != null) {
            for (ResourceInjectionTargetMetaData injectionTarget : entry.getInjectionTargets()) {
                final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
                final String injectionTargetName = injectionTarget.getInjectionTargetName();
                final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, classLoader, deploymentReflectionIndex);
                final Class<?> injectionTargetType = fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getType() : ((Method) fieldOrMethod).getParameterTypes()[0];
                final String memberName = fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getName() : ((Method) fieldOrMethod).getName();

                if (classType != null) {
                    if (!injectionTargetType.isAssignableFrom(classType)) {
                        boolean ok = false;
                        if (classType.isPrimitive()) {
                            if (BOXED_TYPES.get(classType).equals(injectionTargetType)) {
                                ok = true;
                            }
                        } else if (injectionTargetType.isPrimitive()) {
                            if (BOXED_TYPES.get(injectionTargetType).equals(classType)) {
                                ok = true;
                            }
                        }
                        if (!ok) {
                            throw EeLogger.ROOT_LOGGER.invalidInjectionTarget(injectionTarget.getInjectionTargetName(), injectionTarget.getInjectionTargetClass(), classType);
                        }
                        classType = injectionTargetType;
                    }
                } else {
                    classType = injectionTargetType;
                }
                final InjectionTarget injectionTargetDescription = fieldOrMethod instanceof Field ?
                        new FieldInjectionTarget(injectionTargetClassName, memberName, classType.getName()) :
                        new MethodInjectionTarget(injectionTargetClassName, memberName, classType.getName());

                final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTargetDescription, injectionSource);
                resourceInjectionTarget.addResourceInjection(injectionConfiguration);
            }
        }
        return classType;
    }

protected Class < ? > processInjectionTargets ( final ResourceInjectionTarget resourceInjectionTarget , InjectionSource injectionSource , ClassLoader classLoader , DeploymentReflectionIndex deploymentReflectionIndex , ResourceInjectionMetaData entry , Class < ? > classType ) throws DeploymentUnitProcessingException { if ( entry . getInjectionTargets ( ) != null ) { for ( ResourceInjectionTargetMetaData injectionTarget : entry . getInjectionTargets ( ) ) { final String injectionTargetClassName = injectionTarget . getInjectionTargetClass ( ) ; final String injectionTargetName = injectionTarget . getInjectionTargetName ( ) ; final AccessibleObject fieldOrMethod = getInjectionTarget ( injectionTargetClassName , injectionTargetName , classLoader , deploymentReflectionIndex ) ; final Class < ? > injectionTargetType = fieldOrMethod instanceof Field ? ( ( Field ) fieldOrMethod ) . getType ( ) : ( ( Method ) fieldOrMethod ) . getParameterTypes ( ) [ 0 ] ; final String memberName = fieldOrMethod instanceof Field ? ( ( Field ) fieldOrMethod ) . getName ( ) : ( ( Method ) fieldOrMethod ) . getName ( ) ; if ( classType != null ) { if ( ! injectionTargetType . isAssignableFrom ( classType ) ) { boolean ok = false ; if ( classType . isPrimitive ( ) ) { if ( BOXED_TYPES . get ( classType ) . equals ( injectionTargetType ) ) { ok = true ; } } else if ( injectionTargetType . isPrimitive ( ) ) { if ( BOXED_TYPES . get ( injectionTargetType ) . equals ( classType ) ) { ok = true ; } } if ( ! ok ) { throw EeLogger . ROOT_LOGGER . invalidInjectionTarget ( injectionTarget . getInjectionTargetName ( ) , injectionTarget . getInjectionTargetClass ( ) , classType ) ; } classType = injectionTargetType ; } } else { classType = injectionTargetType ; } final InjectionTarget injectionTargetDescription = fieldOrMethod instanceof Field ? new FieldInjectionTarget ( injectionTargetClassName , memberName , classType . getName ( ) ) : new MethodInjectionTarget ( injectionTargetClassName , memberName , classType . getName ( ) ) ; final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration ( injectionTargetDescription , injectionSource ) ; resourceInjectionTarget . addResourceInjection ( injectionConfiguration ) ; } } return classType ; }

Processes the injection targets of a resource binding

@param injectionSource           The injection source for the injection target
@param classLoader               The module class loader
@param deploymentReflectionIndex The deployment reflection index
@param entry                     The resource with injection targets
@param classType                 The expected type of the injection point, may be null if this is to be inferred from the injection target
@return The actual class type of the injection point
@throws DeploymentUnitProcessingException
If the injection points could not be resolved


@Override
    public void stop(final StopContext context) {
        final WeldBootstrapService bootstrapService = bootstrapSupplier.get();
        if (!bootstrapService.isStarted()) {
            throw WeldLogger.ROOT_LOGGER.notStarted("WeldContainer");
        }
        WeldLogger.DEPLOYMENT_LOGGER.stoppingWeldService(bootstrapService.getDeploymentName());
        ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(bootstrapService.getDeployment().getModule().getClassLoader());
            WeldProvider.containerShutDown(Container.instance(bootstrapService.getDeploymentName()));
            bootstrapService.getBootstrap().shutdown();
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
            ModuleGroupSingletonProvider.removeClassLoader(bootstrapService.getDeployment().getModule().getClassLoader());
        }
        bootstrapService.setStarted(false);
    }

@ Override public void stop ( final StopContext context ) { final WeldBootstrapService bootstrapService = bootstrapSupplier . get ( ) ; if ( ! bootstrapService . isStarted ( ) ) { throw WeldLogger . ROOT_LOGGER . notStarted ( "WeldContainer" ) ; } WeldLogger . DEPLOYMENT_LOGGER . stoppingWeldService ( bootstrapService . getDeploymentName ( ) ) ; ClassLoader oldTccl = WildFlySecurityManager . getCurrentContextClassLoaderPrivileged ( ) ; try { WildFlySecurityManager . setCurrentContextClassLoaderPrivileged ( bootstrapService . getDeployment ( ) . getModule ( ) . getClassLoader ( ) ) ; WeldProvider . containerShutDown ( Container . instance ( bootstrapService . getDeploymentName ( ) ) ) ; bootstrapService . getBootstrap ( ) . shutdown ( ) ; } finally { WildFlySecurityManager . setCurrentContextClassLoaderPrivileged ( oldTccl ) ; ModuleGroupSingletonProvider . removeClassLoader ( bootstrapService . getDeployment ( ) . getModule ( ) . getClassLoader ( ) ) ; } bootstrapService . setStarted ( false ) ; }

Stops the container
Executed in WeldStartService to shutdown the runtime before NamingService is closed.

@throws IllegalStateException if the container is not running

Stops the container Executed in WeldStartService to shutdown the runtime before NamingService is closed .


public static String getJndiName(final OperationContext context, final ModelNode modelNode) throws OperationFailedException {
        final String rawJndiName = JNDI_NAME.resolveModelAttribute(context, modelNode).asString();
        return cleanJndiName(rawJndiName, modelNode.hasDefined(USE_JAVA_CONTEXT.getName()) && modelNode.get(USE_JAVA_CONTEXT.getName()).asBoolean());
    }

public static String getJndiName ( final OperationContext context , final ModelNode modelNode ) throws OperationFailedException { final String rawJndiName = JNDI_NAME . resolveModelAttribute ( context , modelNode ) . asString ( ) ; return cleanJndiName ( rawJndiName , modelNode . hasDefined ( USE_JAVA_CONTEXT . getName ( ) ) && modelNode . get ( USE_JAVA_CONTEXT . getName ( ) ) . asBoolean ( ) ) ; }

Extracts the raw JNDINAME value from the given model node, and depending on the value and
the value of any USE_JAVA_CONTEXT child node, converts the raw name into a compliant jndi name.

@param modelNode the model node; either an operation or the model behind a datasource resource

@return the compliant jndi name

Extracts the raw JNDINAME value from the given model node and depending on the value and the value of any USE_JAVA_CONTEXT child node converts the raw name into a compliant jndi name .


private String resolveAttribute(SimpleAttributeDefinition attr, OperationContext context, ModelNode model) throws OperationFailedException {
        final ModelNode node = attr.resolveModelAttribute(context, model);
        return node.isDefined() ? node.asString() : null;
    }

private String resolveAttribute ( SimpleAttributeDefinition attr , OperationContext context , ModelNode model ) throws OperationFailedException { final ModelNode node = attr . resolveModelAttribute ( context , model ) ; return node . isDefined ( ) ? node . asString ( ) : null ; }

Return null if the resolved attribute is not defined


static int getPatternType(String urlPattern) {
        int type = EXACT;
        if (urlPattern.startsWith("*."))
            type = EXTENSION;
        else if (urlPattern.startsWith("/") && urlPattern.endsWith("/*"))
            type = PREFIX;
        else if (urlPattern.equals("/"))
            type = DEFAULT;
        return type;
    }

static int getPatternType ( String urlPattern ) { int type = EXACT ; if ( urlPattern . startsWith ( "*." ) ) type = EXTENSION ; else if ( urlPattern . startsWith ( "/" ) && urlPattern . endsWith ( "/*" ) ) type = PREFIX ; else if ( urlPattern . equals ( "/" ) ) type = DEFAULT ; return type ; }

Determine the url-pattern type

@param urlPattern - the raw url-pattern value
@return one of EXACT, EXTENSION, PREFIX, DEFAULT


static boolean targetsPooledConnectionFactory(String server, String resourceAdapter, ServiceRegistry serviceRegistry) {
        // if the resourceAdapter is not defined, the default behaviour is to create a pooled-connection-factory.
        if (resourceAdapter == null || resourceAdapter.isEmpty()) {
            return true;
        }
        ServiceName activeMQServiceName = MessagingServices.getActiveMQServiceName(server);
        ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(activeMQServiceName).append(resourceAdapter);
        return serviceRegistry.getServiceNames().contains(pcfName);
    }

Return whether the definition targets an existing pooled connection factory or use a JCA-based ConnectionFactory.

Checks the service registry for a PooledConnectionFactoryService with the ServiceName
created by the {@code server} property (or {@code "default") and the {@code resourceAdapter} property.

Return whether the definition targets an existing pooled connection factory or use a JCA - based ConnectionFactory .


static boolean targetsExternalPooledConnectionFactory(String resourceAdapter, ServiceRegistry serviceRegistry) {
        // if the resourceAdapter is not defined, the default behaviour is to create a pooled-connection-factory.
        if (resourceAdapter == null || resourceAdapter.isEmpty()) {
            return false;
        }
        //let's look into the external-pooled-connection-factory
        ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName("")).append(resourceAdapter);
        return serviceRegistry.getServiceNames().contains(pcfName);
    }

Return whether the definition targets an existing external pooled connection factory.

Checks the service registry for a PooledConnectionFactoryService with the ServiceName
created by the {@code server} property (or {@code "default") and the {@code resourceAdapter} property.

Return whether the definition targets an existing external pooled connection factory .


static String getActiveMQServerName(Map<String, String> properties) {
        return properties.getOrDefault(SERVER, DEFAULT);
    }

static String getActiveMQServerName ( Map < String , String > properties ) { return properties . getOrDefault ( SERVER , DEFAULT ) ; }

The JMS connection factory can specify another server to deploy its destinations
by passing a property server=<name of the server>. Otherwise, "default" is used by default.

The JMS connection factory can specify another server to deploy its destinations by passing a property server = &lt ; name of the server > . Otherwise default is used by default .


private static String defaultPersistenceUnitName(String persistenceUnitName, PersistenceUnitMetadataHolder holder) {
        if ((persistenceUnitName == null || persistenceUnitName.length() == 0)) {
            for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
                String defaultPU = persistenceUnit.getProperties().getProperty(Configuration.JPA_DEFAULT_PERSISTENCE_UNIT);
                if(Boolean.TRUE.toString().equals(defaultPU)) {
                    persistenceUnitName = persistenceUnit.getPersistenceUnitName();
                }
            }
        }
        return persistenceUnitName;
    }

private static String defaultPersistenceUnitName ( String persistenceUnitName , PersistenceUnitMetadataHolder holder ) { if ( ( persistenceUnitName == null || persistenceUnitName . length ( ) == 0 ) ) { for ( PersistenceUnitMetadata persistenceUnit : holder . getPersistenceUnits ( ) ) { String defaultPU = persistenceUnit . getProperties ( ) . getProperty ( Configuration . JPA_DEFAULT_PERSISTENCE_UNIT ) ; if ( Boolean . TRUE . toString ( ) . equals ( defaultPU ) ) { persistenceUnitName = persistenceUnit . getPersistenceUnitName ( ) ; } } } return persistenceUnitName ; }

if no persistence unit name is specified, return name of default persistence unit

@param persistenceUnitName that was specified to be used (null means to use the default persistence unit)
@param holder
@return

if no persistence unit name is specified return name of default persistence unit


public void start(StartContext context) {
        final SuspendController suspendController = suspendControllerInjectedValue.getValue();
        suspendController.registerActivity(this);
        final LocalTransactionContext localTransactionContext = localTransactionContextInjectedValue.getValue();
        localTransactionContext.registerCreationListener(this);
    }

public void start ( StartContext context ) { final SuspendController suspendController = suspendControllerInjectedValue . getValue ( ) ; suspendController . registerActivity ( this ) ; final LocalTransactionContext localTransactionContext = localTransactionContextInjectedValue . getValue ( ) ; localTransactionContext . registerCreationListener ( this ) ; }

Starts the service. Registers server activity, sets transaction listener on local transaction context, and creates and
installs deployment controller service.

@param context start context

Starts the service . Registers server activity sets transaction listener on local transaction context and creates and installs deployment controller service .


public void stop(StopContext context) {
        final SuspendController suspendController = suspendControllerInjectedValue.getValue();
        suspendController.unRegisterActivity(this);
        final LocalTransactionContext localTransactionContext = localTransactionContextInjectedValue.getValue();
        localTransactionContext.removeCreationListener(this);
    }

public void stop ( StopContext context ) { final SuspendController suspendController = suspendControllerInjectedValue . getValue ( ) ; suspendController . unRegisterActivity ( this ) ; final LocalTransactionContext localTransactionContext = localTransactionContextInjectedValue . getValue ( ) ; localTransactionContext . removeCreationListener ( this ) ; }

Stops the service. Unregisters service activity and clears transaction listener.
@param context stop context

Stops the service . Unregisters service activity and clears transaction listener .


@Override public void suspended(ServerActivityCallback listener) {
        this.suspended = true;
        listenerUpdater.set(this, listener);
        localTransactionContextInjectedValue.getValue().suspendRequests();

        final int activeInvocationCount = activeInvocationCountUpdater.get(this);
        if (activeInvocationCount == 0) {
            if (gracefulTxnShutdown) {
                if (activeTransactionCountUpdater.get(this) == 0) {
                    this.doneSuspended();
                } else {
                    EjbLogger.ROOT_LOGGER.suspensionWaitingActiveTransactions(activeInvocationCount);
                }
            } else {
                this.doneSuspended();
            }
        }
    }

@ Override public void suspended ( ServerActivityCallback listener ) { this . suspended = true ; listenerUpdater . set ( this , listener ) ; localTransactionContextInjectedValue . getValue ( ) . suspendRequests ( ) ; final int activeInvocationCount = activeInvocationCountUpdater . get ( this ) ; if ( activeInvocationCount == 0 ) { if ( gracefulTxnShutdown ) { if ( activeTransactionCountUpdater . get ( this ) == 0 ) { this . doneSuspended ( ) ; } else { EjbLogger . ROOT_LOGGER . suspensionWaitingActiveTransactions ( activeInvocationCount ) ; } } else { this . doneSuspended ( ) ; } } }

Notifies local transaction context that server is suspended, and only completes suspension if
there are no active invocations nor transactions.

@param listener callback listener

Notifies local transaction context that server is suspended and only completes suspension if there are no active invocations nor transactions .


@Override public void resume() {
        this.suspended = false;
        localTransactionContextInjectedValue.getValue().resumeRequests();
        ServerActivityCallback listener = listenerUpdater.get(this);
        if (listener != null) {
            listenerUpdater.compareAndSet(this, listener, null);
        }
        deploymentRepositoryInjectedValue.getValue().resume();
    }

@ Override public void resume ( ) { this . suspended = false ; localTransactionContextInjectedValue . getValue ( ) . resumeRequests ( ) ; ServerActivityCallback listener = listenerUpdater . get ( this ) ; if ( listener != null ) { listenerUpdater . compareAndSet ( this , listener , null ) ; } deploymentRepositoryInjectedValue . getValue ( ) . resume ( ) ; }

Notifies local transaction context that server is resumed, and restarts deployment controller.

Notifies local transaction context that server is resumed and restarts deployment controller .


public void invocationComplete() {
        int activeInvocations = activeInvocationCountUpdater.decrementAndGet(this);
        if (suspended && activeInvocations == 0 && (!gracefulTxnShutdown || (activeTransactionCountUpdater.get(this) == 0))) {
            doneSuspended();
        }
    }

public void invocationComplete ( ) { int activeInvocations = activeInvocationCountUpdater . decrementAndGet ( this ) ; if ( suspended && activeInvocations == 0 && ( ! gracefulTxnShutdown || ( activeTransactionCountUpdater . get ( this ) == 0 ) ) ) { doneSuspended ( ) ; } }

Notifies handler that an active invocation is complete.

Notifies handler that an active invocation is complete .


@Override public void transactionCreated(AbstractTransaction transaction, CreatedBy createdBy) {
        activeTransactionCountUpdater.incrementAndGet(this);
        try {
            transaction.registerSynchronization(this);
        } catch (RollbackException | IllegalStateException e) {
            // it means the transaction is marked for rollback, or is prepared for commit, at this point we cannot register synchronization
            decrementTransactionCount();
        } catch (SystemException e) {
            decrementTransactionCount();
            EjbLogger.ROOT_LOGGER.debug("Unexpected exception", e);
            throw new RuntimeException(e);
        }
    }

Notifies handler that a new transaction has been created.

Notifies handler that a new transaction has been created .


public void start(StartContext context) throws StartException {
        final ServiceBasedNamingStore namingStore = namingStoreValue.getValue();
        controller = context.getController();
        namingStore.add(controller.getName());
        ROOT_LOGGER.tracef("Bound resource %s into naming store %s (service name %s)", name, namingStore, controller.getName());
    }

Bind the entry into the injected context.

@param context The start context
@throws StartException If the entity can not be bound

Bind the entry into the injected context .


public void stop(StopContext context) {
        final ServiceBasedNamingStore namingStore = namingStoreValue.getValue();
        namingStore.remove(controller.getName());
        ROOT_LOGGER.tracef("Unbound resource %s into naming store %s (service name %s)", name, namingStore, context.getController().getName());
    }

Unbind the entry from the injected context.

@param context The stop context

Unbind the entry from the injected context .


public static ServiceName getCapabilityServiceName(String capabilityBaseName, String... dynamicParts) {
        if (capabilityServiceSupport == null) {
            throw new IllegalStateException();
        }
        if (dynamicParts == null || dynamicParts.length == 0) {
            return capabilityServiceSupport.getCapabilityServiceName(capabilityBaseName);
        }
        return capabilityServiceSupport.getCapabilityServiceName(capabilityBaseName, dynamicParts);
    }

public static ServiceName getCapabilityServiceName ( String capabilityBaseName , String ... dynamicParts ) { if ( capabilityServiceSupport == null ) { throw new IllegalStateException ( ) ; } if ( dynamicParts == null || dynamicParts . length == 0 ) { return capabilityServiceSupport . getCapabilityServiceName ( capabilityBaseName ) ; } return capabilityServiceSupport . getCapabilityServiceName ( capabilityBaseName , dynamicParts ) ; }

Determines a ServiceName from a capability name. Only supported for use by services installed by
this subsystem; will not function reliably until the subsystem has begun adding runtime services.

@param capabilityBaseName the base name of the capability, or its full name if it is not dynamic
@param dynamicParts any dynamic parts of the capability name. May be {@code null}
@return the service name

@throws IllegalStateException if invoked before the subsystem has begun adding runtime services

Determines a ServiceName from a capability name . Only supported for use by services installed by this subsystem ; will not function reliably until the subsystem has begun adding runtime services .


private List<ResourceRoot> createResourceRoots(final VirtualFile deploymentRoot, final DeploymentUnit deploymentUnit) throws IOException, DeploymentUnitProcessingException {
        final List<ResourceRoot> entries = new ArrayList<ResourceRoot>();
        // WEB-INF classes
        final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES);
        if (webinfClasses.exists()) {
            final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null);
            ModuleRootMarker.mark(webInfClassesRoot);
            entries.add(webInfClassesRoot);
        }
        // WEB-INF lib
        Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
        final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB);
        if (webinfLib.exists()) {
            final List<VirtualFile> archives = webinfLib.getChildren(DEFAULT_WEB_INF_LIB_FILTER);
            for (final VirtualFile archive : archives) {
                try {

                    String relativeName = archive.getPathNameRelativeTo(deploymentRoot);
                    MountedDeploymentOverlay overlay = overlays.get(relativeName);
                    Closeable closable = null;
                    if(overlay != null) {
                        overlay.remountAsZip(false);
                    } else if (archive.isFile()) {
                        closable = VFS.mountZip(archive, archive, TempFileProviderService.provider());
                    } else {
                        closable = null;
                    }
                    final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable));
                    ModuleRootMarker.mark(webInfArchiveRoot);
                    entries.add(webInfArchiveRoot);
                } catch (IOException e) {
                    throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToProcessWebInfLib(archive), e);
                }
            }
        }
        return entries;
    }

private
List
<
ResourceRoot
>
createResourceRoots
(
final
VirtualFile
deploymentRoot
,
final
DeploymentUnit
deploymentUnit
)
throws
IOException
,
DeploymentUnitProcessingException
{
final
List
<
ResourceRoot
>
entries
=
new
ArrayList
<
ResourceRoot
>
(
)
;
// WEB-INF classes
final
VirtualFile
webinfClasses
=
deploymentRoot
.
getChild
(
WEB_INF_CLASSES
)
;
if
(
webinfClasses
.
exists
(
)
)
{
final
ResourceRoot
webInfClassesRoot
=
new
ResourceRoot
(
webinfClasses
.
getName
(
)
,
webinfClasses
,
)
;
ModuleRootMarker
.
mark
(
webInfClassesRoot
)
;
entries
.
add
(
webInfClassesRoot
)
;
}
// WEB-INF lib
Map
<
String
,
MountedDeploymentOverlay
>
overlays
=
deploymentUnit
.
getAttachment
(
Attachments
.
DEPLOYMENT_OVERLAY_LOCATIONS
)
;
final
VirtualFile
webinfLib
=
deploymentRoot
.
getChild
(
WEB_INF_LIB
)
;
if
(
webinfLib
.
exists
(
)
)
{
final
List
<
VirtualFile
>
archives
=
webinfLib
.
getChildren
(
DEFAULT_WEB_INF_LIB_FILTER
)
;
for
(
final
VirtualFile
archive
:
archives
)
{
try
{
String
relativeName
=
archive
.
getPathNameRelativeTo
(
deploymentRoot
)
;
MountedDeploymentOverlay
overlay
=
overlays
.
get
(
relativeName
)
;
Closeable
closable
=
;
if
(
overlay
!=
)
{
overlay
.
remountAsZip
(
false
)
;
}
else
if
(
archive
.
isFile
(
)
)
{
closable
=
VFS
.
mountZip
(
archive
,
archive
,
TempFileProviderService
.
provider
(
)
)
;
}
else
{
closable
=
;
}
final
ResourceRoot
webInfArchiveRoot
=
new
ResourceRoot
(
archive
.
getName
(
)
,
archive
,
new
MountHandle
(
closable
)
)
;
ModuleRootMarker
.
mark
(
webInfArchiveRoot
)
;
entries
.
add
(
webInfArchiveRoot
)
;
}
catch
(
IOException
e
)
{
throw
new
DeploymentUnitProcessingException
(
UndertowLogger
.
ROOT_LOGGER
.
failToProcessWebInfLib
(
archive
)
,
e
)
;
}
}
}
return
entries
;
}

Create the resource roots for a .war deployment

@param deploymentRoot the deployment root
@return the resource roots
@throws java.io.IOException for any error

Create the resource roots for a . war deployment


private static Set<ClassLoader> allDeploymentModuleClassLoaders(DeploymentUnit deploymentUnit) {
        Set<ClassLoader> deploymentClassLoaders = new HashSet<ClassLoader>();
        final DeploymentUnit topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(deploymentUnit);
        final Module toplevelModule = topDeploymentUnit.getAttachment(Attachments.MODULE);
        if (toplevelModule != null) {
            deploymentClassLoaders.add(toplevelModule.getClassLoader());
            final List<DeploymentUnit> subDeployments = topDeploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
            for (DeploymentUnit subDeploymentUnit: subDeployments) {
                final Module subDeploymentModule = subDeploymentUnit.getAttachment(Attachments.MODULE);
                if (subDeploymentModule != null) {
                    deploymentClassLoaders.add(subDeploymentModule.getClassLoader());
                }
            }
        }
        return deploymentClassLoaders;
    }

private static Set < ClassLoader > allDeploymentModuleClassLoaders ( DeploymentUnit deploymentUnit ) { Set < ClassLoader > deploymentClassLoaders = new HashSet < ClassLoader > ( ) ; final DeploymentUnit topDeploymentUnit = DeploymentUtils . getTopDeploymentUnit ( deploymentUnit ) ; final Module toplevelModule = topDeploymentUnit . getAttachment ( Attachments . MODULE ) ; if ( toplevelModule != null ) { deploymentClassLoaders . add ( toplevelModule . getClassLoader ( ) ) ; final List < DeploymentUnit > subDeployments = topDeploymentUnit . getAttachmentList ( Attachments . SUB_DEPLOYMENTS ) ; for ( DeploymentUnit subDeploymentUnit : subDeployments ) { final Module subDeploymentModule = subDeploymentUnit . getAttachment ( Attachments . MODULE ) ; if ( subDeploymentModule != null ) { deploymentClassLoaders . add ( subDeploymentModule . getClassLoader ( ) ) ; } } } return deploymentClassLoaders ; }

returns the toplevel deployment module classloader and all subdeployment classloaders

@param deploymentUnit
@return


public static boolean needClassFileTransformer(PersistenceUnitMetadata pu) {
        boolean result = true;
        String provider = pu.getPersistenceProviderClassName();
        if (pu.getProperties().containsKey(Configuration.JPA_CONTAINER_CLASS_TRANSFORMER)) {
            result = Boolean.parseBoolean(pu.getProperties().getProperty(Configuration.JPA_CONTAINER_CLASS_TRANSFORMER));
        }
        else if (isHibernateProvider(provider)) {
            result = (Boolean.TRUE.toString().equals(pu.getProperties().getProperty(HIBERNATE_USE_CLASS_ENHANCER))
                    || Boolean.TRUE.toString().equals(pu.getProperties().getProperty(HIBERNATE_ENABLE_DIRTY_TRACKING))
                    || Boolean.TRUE.toString().equals(pu.getProperties().getProperty(HIBERNATE_ENABLE_LAZY_INITIALIZATION))
                    || Boolean.TRUE.toString().equals(pu.getProperties().getProperty(HIBERNATE_ENABLE_ASSOCIATION_MANAGEMENT)));
        }
        return result;
    }

public static boolean needClassFileTransformer ( PersistenceUnitMetadata pu ) { boolean result = true ; String provider = pu . getPersistenceProviderClassName ( ) ; if ( pu . getProperties ( ) . containsKey ( Configuration . JPA_CONTAINER_CLASS_TRANSFORMER ) ) { result = Boolean . parseBoolean ( pu . getProperties ( ) . getProperty ( Configuration . JPA_CONTAINER_CLASS_TRANSFORMER ) ) ; } else if ( isHibernateProvider ( provider ) ) { result = ( Boolean . TRUE . toString ( ) . equals ( pu . getProperties ( ) . getProperty ( HIBERNATE_USE_CLASS_ENHANCER ) ) || Boolean . TRUE . toString ( ) . equals ( pu . getProperties ( ) . getProperty ( HIBERNATE_ENABLE_DIRTY_TRACKING ) ) || Boolean . TRUE . toString ( ) . equals ( pu . getProperties ( ) . getProperty ( HIBERNATE_ENABLE_LAZY_INITIALIZATION ) ) || Boolean . TRUE . toString ( ) . equals ( pu . getProperties ( ) . getProperty ( HIBERNATE_ENABLE_ASSOCIATION_MANAGEMENT ) ) ) ; } return result ; }

Determine if class file transformer is needed for the specified persistence unit

if the persistence provider is Hibernate and use_class_enhancer is not true, don't need a class transformer.
for other persistence providers, the transformer is assumed to be needed.

@param pu the PU
@return true if class file transformer support is needed for pu


public static boolean allowTwoPhaseBootstrap(PersistenceUnitMetadata pu) {
        boolean result = true;

        if (EE_DEFAULT_DATASOURCE.equals(pu.getJtaDataSourceName())) {
            result = false;
        }
        if (pu.getProperties().containsKey(Configuration.JPA_ALLOW_TWO_PHASE_BOOTSTRAP)) {
            result = Boolean.parseBoolean(pu.getProperties().getProperty(Configuration.JPA_ALLOW_TWO_PHASE_BOOTSTRAP));
        }
        return result;
    }

public static boolean allowTwoPhaseBootstrap ( PersistenceUnitMetadata pu ) { boolean result = true ; if ( EE_DEFAULT_DATASOURCE . equals ( pu . getJtaDataSourceName ( ) ) ) { result = false ; } if ( pu . getProperties ( ) . containsKey ( Configuration . JPA_ALLOW_TWO_PHASE_BOOTSTRAP ) ) { result = Boolean . parseBoolean ( pu . getProperties ( ) . getProperty ( Configuration . JPA_ALLOW_TWO_PHASE_BOOTSTRAP ) ) ; } return result ; }

Determine if two phase persistence unit start is allowed

@param pu
@return


public static boolean allowDefaultDataSourceUse(PersistenceUnitMetadata pu) {
        boolean result = true;
        if (pu.getProperties().containsKey(Configuration.JPA_ALLOW_DEFAULT_DATA_SOURCE_USE)) {
            result = Boolean.parseBoolean(pu.getProperties().getProperty(Configuration.JPA_ALLOW_DEFAULT_DATA_SOURCE_USE));
        }
        return result;
    }

public static boolean allowDefaultDataSourceUse ( PersistenceUnitMetadata pu ) { boolean result = true ; if ( pu . getProperties ( ) . containsKey ( Configuration . JPA_ALLOW_DEFAULT_DATA_SOURCE_USE ) ) { result = Boolean . parseBoolean ( pu . getProperties ( ) . getProperty ( Configuration . JPA_ALLOW_DEFAULT_DATA_SOURCE_USE ) ) ; } return result ; }

Determine if the default data-source should be used

@param pu
@return true if the default data-source should be used

Determine if the default data - source should be used


public static boolean skipMixedSynchronizationTypeCheck(EntityManagerFactory emf, Map targetEntityManagerProperties) {
        boolean result = false;
        // EntityManager properties will take priority over persistence.xml level (emf) properties
        if(targetEntityManagerProperties != null && targetEntityManagerProperties.containsKey(SKIPMIXEDSYNCTYPECHECKING)) {
            result = Boolean.parseBoolean((String) targetEntityManagerProperties.get(SKIPMIXEDSYNCTYPECHECKING));
        }
        else if(emf.getProperties() != null && emf.getProperties().containsKey(SKIPMIXEDSYNCTYPECHECKING)) {
            result = Boolean.parseBoolean((String) emf.getProperties().get(SKIPMIXEDSYNCTYPECHECKING));
        }
        return result;
    }

Allow the mixed synchronization checking to be skipped for backward compatibility with WildFly 10.1.0

@param emf
@param targetEntityManagerProperties
@return

Allow the mixed synchronization checking to be skipped for backward compatibility with WildFly 10 . 1 . 0


public static ORB getOrb(String server, int port, Hashtable env) {
        // See if we can get info from environment
        Properties orbProp;

        // Extract any org.omg.CORBA properties from environment
        if (env != null) {
            // Get all String properties
            orbProp = new Properties();
            final Enumeration envProp = env.keys();
            while (envProp.hasMoreElements()) {
                String key = (String) envProp.nextElement();
                Object val = env.get(key);
                if (val instanceof String) {
                    orbProp.put(key, val);
                }
            }
            final Enumeration mainProps = orbProperties.keys();
            while (mainProps.hasMoreElements()) {
                String key = (String) mainProps.nextElement();
                Object val = orbProperties.get(key);
                if (val instanceof String) {
                    orbProp.put(key, val);
                }
            }
        } else {
            orbProp = orbProperties;
        }

        if (server != null) {
            orbProp.put("org.omg.CORBA.ORBInitialHost", server);
        }
        if (port >= 0) {
            orbProp.put("org.omg.CORBA.ORBInitialPort", "" + port);
        }

        // Get Applet from environment
        if (env != null) {
            Object applet = env.get(Context.APPLET);
            if (applet != null) {
                // Create ORBs for an applet
                return initAppletORB(applet, orbProp);
            }
        }

        // Create ORBs using orbProp for a standalone application
        return ORB.init(new String[0], orbProp);
    }

Get ORB using given server and port number, and properties from environment.

@param server Possibly null server; if null means use default;
For applet, it is the applet host; for app, it is localhost.
@param port   Port number, -1 means default port
@param env    Possibly null environment. Contains environment properties.
Could contain ORB itself; or applet used for initializing ORB.
Use all String properties from env for initializing ORB
@return A non-null ORB.

Get ORB using given server and port number and properties from environment .


private static ORB initAppletORB(Object applet, Properties orbProp) {
        try {
            Class<?> appletClass = Class.forName("java.applet.Applet", true, null);
            if (!appletClass.isInstance(applet)) {
                throw new ClassCastException(applet.getClass().getName());
            }

            // invoke the static method ORB.init(applet, orbProp);
            Method method = ORB.class.getMethod("init", appletClass, Properties.class);
            return (ORB) method.invoke(null, applet, orbProp);
        } catch (ClassNotFoundException e) {
            // java.applet.Applet doesn't exist and the applet parameter is
            // non-null; so throw CCE
            throw new ClassCastException(applet.getClass().getName());
        } catch (NoSuchMethodException e) {
            throw new AssertionError(e);
        } catch (InvocationTargetException e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            } else if (cause instanceof Error) {
                throw (Error) cause;
            }
            throw new AssertionError(e);
        } catch (IllegalAccessException iae) {
            throw new AssertionError(iae);
        }
    }

This method returns a new ORB instance for the given applet
without creating a static dependency on java.applet.

This method returns a new ORB instance for the given applet without creating a static dependency on java . applet .


private static void initMethodHandles() throws ClassNotFoundException {
        // Get javax.rmi.CORBA.Stub class
        corbaStubClass = Class.forName("javax.rmi.CORBA.Stub");

        // Get javax.rmi.CORBA.Stub.connect(org.omg.CORBA.ORB) method

        try {
            connectMethod = corbaStubClass.getMethod("connect", new Class[]{org.omg.CORBA.ORB.class});
        } catch (NoSuchMethodException e) {
            throw IIOPLogger.ROOT_LOGGER.noMethodDefForStubConnect();
        }

        // Get javax.rmi.PortableRemoteObject method
        Class proClass = Class.forName("javax.rmi.PortableRemoteObject");

        // Get javax.rmi.PortableRemoteObject(java.rmi.Remote) method
        try {
            toStubMethod = proClass.getMethod("toStub", new Class[]{java.rmi.Remote.class});

        } catch (NoSuchMethodException e) {
            throw IIOPLogger.ROOT_LOGGER.noMethodDefForPortableRemoteObjectToStub();
        }
    }

Initializes reflection method handles for RMI-IIOP.

@throws ClassNotFoundException javax.rmi.CORBA.* not available

Initializes reflection method handles for RMI - IIOP .


public static void setActiveNamingStore(final NamingStore namingStore) {
        if(WildFlySecurityManager.isChecking()) {
            System.getSecurityManager().checkPermission(SET_ACTIVE_NAMING_STORE);
        }
        ACTIVE_NAMING_STORE = namingStore;
    }

public static void setActiveNamingStore ( final NamingStore namingStore ) { if ( WildFlySecurityManager . isChecking ( ) ) { System . getSecurityManager ( ) . checkPermission ( SET_ACTIVE_NAMING_STORE ) ; } ACTIVE_NAMING_STORE = namingStore ; }

Set the active naming store

@param namingStore The naming store


private void validateDefaultValues(List<ParamDetail> detailList,
                                       HashMap<String, List<Validator>> paramConverterMap)
            throws DeploymentUnitProcessingException {

        for(ParamDetail detail : detailList) {

            // check param converter for specific return type
            List<Validator> validators = paramConverterMap.get(
                    detail.parameter.getName());

            if (validators == null) {
                // check for paramConverterProvider
                validators = paramConverterMap.get(Object.class.getName());
            }

            boolean isCheckClazzMethods = true;
            if (validators != null) {
                for (Validator v : validators) {
                    if (!v.isLazyLoad()) {
                        try {
                            Object obj = v.verify(detail);
                            if (obj != null) {
                                isCheckClazzMethods = false;
                                break;
                            }
                        } catch (Exception e) {
                            JAXRS_LOGGER.paramConverterFailed(detail.defaultValue.value(),
                                    detail.parameter.getSimpleName(),
                                    detail.method.toString(),
                                    v.toString(), e.getClass().getName(),
                                    e.getMessage());
                        }
                    }
                }
            }

            if (isCheckClazzMethods) {
                Class baseType = detail.parameter;
                Method valueOf = null;

                // constructor rule
                try {
                    Constructor<?> ctor = baseType.getConstructor(String.class);
                    if (Modifier.isPublic(ctor.getModifiers())) {
                        continue; // success move to next detail
                    }
                } catch (NoSuchMethodException ignored) { }

                // method fromValue(String.class) rule
                try {
                    Method fromValue = baseType.getDeclaredMethod("fromValue", String.class);
                    if (Modifier.isPublic(fromValue.getModifiers())) {
                        for (Annotation ann : baseType.getAnnotations()) {
                            if (ann.annotationType().getName()
                                    .equals("javax.xml.bind.annotation.XmlEnum")) {
                                valueOf = fromValue;
                            }
                        }
                        validateBaseType(fromValue, detail.defaultValue.value(), detail);
                        continue; // success move to next detail
                    }
                } catch (NoSuchMethodException ignoredA) { }

                // method fromString(String.class) rule
                Method fromString = null;
                try {
                    fromString = baseType.getDeclaredMethod("fromString", String.class);
                    if (Modifier.isStatic(fromString.getModifiers())) {
                        validateBaseType(fromString, detail.defaultValue.value(), detail);
                        continue; // success move to next detail
                    }
                } catch (NoSuchMethodException ignoredB) {
                }

                // method valueof(String.class) rule
                try {
                    valueOf = baseType.getDeclaredMethod("valueOf", String.class);
                    if (Modifier.isStatic(valueOf.getModifiers())) {
                        validateBaseType(valueOf, detail.defaultValue.value(), detail);
                        continue; // success move to next detail
                    }
                } catch (NoSuchMethodException ignored) {
                }

            }
        }

    }

Process all parameter DefaulValue objects.  Flag all parameters with
missing and invalid converters.

@param detailList
@param paramConverterMap

Process all parameter DefaulValue objects . Flag all parameters with missing and invalid converters .


private Class checkParamType(Type genParamType, final Method method,
                                 final int paramPos, final ClassLoader classLoader){

        Class paramClazz = null;

        if (genParamType instanceof ParameterizedType) {
            ParameterizedType pType = (ParameterizedType) genParamType;
            Type[] actualTypeArgs = pType.getActualTypeArguments();
            // skip Map types. Don't know how to set default value for these
            if (actualTypeArgs.length == 1) {
                try {
                    paramClazz = classLoader.loadClass(actualTypeArgs[0].getTypeName());
                } catch (Exception ee) {
                    JAXRS_LOGGER.classIntrospectionFailure(ee.getClass().getName(),
                            ee.getMessage());
                }
            }
        } else {
            Class<?>[] paramArr = method.getParameterTypes();
            if (paramArr[paramPos].isArray()) {
                Class compClazz = paramArr[paramPos].getComponentType();
                if (!compClazz.isPrimitive()) {
                    paramClazz = compClazz;
                }
            } else {
                if (!paramArr[paramPos].isPrimitive()) {
                    paramClazz = paramArr[paramPos];
                }
            }
        }
        return paramClazz;
    }

Take steps to properly identify the parameter's data type
@param genParamType
@param method
@param paramPos
@param classLoader
@return

Take steps to properly identify the parameter s data type


private DefaultValue lookupDefaultValueAnn(Annotation[] annotationArr) {
        for (Annotation ann :  annotationArr) {

            if (ann instanceof DefaultValue) {
                return (DefaultValue)ann;
            }
        }
        return null;
    }

private DefaultValue lookupDefaultValueAnn ( Annotation [ ] annotationArr ) { for ( Annotation ann : annotationArr ) { if ( ann instanceof DefaultValue ) { return ( DefaultValue ) ann ; } } return null ; }

Extract a DefaultValue annotation from the list of parameter annotations
@param annotationArr
@return


private void validateBaseType(Method method, String defaultValue, ParamDetail detail)
        throws DeploymentUnitProcessingException {
        if (defaultValue != null) {
            try {
                method.invoke(method.getDeclaringClass(), defaultValue);
            } catch (Exception e) {
                JAXRS_LOGGER.baseTypeMethodFailed(defaultValue,
                        detail.parameter.getSimpleName(), detail.method.toString(),
                        method.toString(), e.getClass().getName(),
                        e.getMessage());
            }
        }
    }

private void validateBaseType ( Method method , String defaultValue , ParamDetail detail ) throws DeploymentUnitProcessingException { if ( defaultValue != null ) { try { method . invoke ( method . getDeclaringClass ( ) , defaultValue ) ; } catch ( Exception e ) { JAXRS_LOGGER . baseTypeMethodFailed ( defaultValue , detail . parameter . getSimpleName ( ) , detail . method . toString ( ) , method . toString ( ) , e . getClass ( ) . getName ( ) , e . getMessage ( ) ) ; } } }

Confirm the method can handle the default value without throwing
and exception.

@param method
@param defaultValue

Confirm the method can handle the default value without throwing and exception .


public static ExtendedEntityManager[] getDeferredEntityManagers() {
        List<ExtendedEntityManager> store = deferToPostConstruct.get();
        try {
            if(store.isEmpty()) {
                return EMPTY;
            } else {
                return store.toArray(new ExtendedEntityManager[store.size()]);
            }
        } finally {
            store.clear();
        }
    }

public static ExtendedEntityManager [ ] getDeferredEntityManagers ( ) { List < ExtendedEntityManager > store = deferToPostConstruct . get ( ) ; try { if ( store . isEmpty ( ) ) { return EMPTY ; } else { return store . toArray ( new ExtendedEntityManager [ store . size ( ) ] ) ; } } finally { store . clear ( ) ; } }


public static String statusAsString(int status) {
        if (status >= Status.STATUS_ACTIVE && status <= Status.STATUS_ROLLING_BACK) {
            return TxStatusStrings[status];
        } else {
            return "STATUS_INVALID(" + status + ")";
        }
    }

public static String statusAsString ( int status ) { if ( status >= Status . STATUS_ACTIVE && status <= Status . STATUS_ROLLING_BACK ) { return TxStatusStrings [ status ] ; } else { return "STATUS_INVALID(" + status + ")" ; } }

Converts a tx Status index to a String

@param status the Status index
@return status as String or "STATUS_INVALID(value)"
@see javax.transaction.Status


public static void addCacheDependencies(Classification cacheType, Properties properties) {
        for(EventListener eventListener: eventListeners) {
            eventListener.addCacheDependencies(cacheType, properties);
        }
    }

public static void addCacheDependencies ( Classification cacheType , Properties properties ) { for ( EventListener eventListener : eventListeners ) { eventListener . addCacheDependencies ( cacheType , properties ) ; } }

add cache dependencies

@param properties


private void extractDialects() {
        for (Object prop : sql.keySet()) {
            int dot = ((String)prop).indexOf('.');
            if (dot > 0) {
                databaseDialects.add(((String)prop).substring(dot+1));
            }
        }
    }

private void extractDialects ( ) { for ( Object prop : sql . keySet ( ) ) { int dot = ( ( String ) prop ) . indexOf ( ' ' ) ; if ( dot > 0 ) { databaseDialects . add ( ( ( String ) prop ) . substring ( dot + 1 ) ) ; } } }

Read the properties from the timer-sql and extract the database dialects.

Read the properties from the timer - sql and extract the database dialects .


private void investigateDialect() {
        Connection connection = null;

        if (database == null) {
            // no database dialect from configuration guessing from MetaData
            try {
                connection = dataSource.getConnection();
                DatabaseMetaData metaData = connection.getMetaData();
                String dbProduct = metaData.getDatabaseProductName();
                database = identifyDialect(dbProduct);

                if (database == null) {
                    EjbLogger.EJB3_TIMER_LOGGER.debug("Attempting to guess on driver name.");
                    database = identifyDialect(metaData.getDriverName());
                }
            } catch (Exception e) {
                EjbLogger.EJB3_TIMER_LOGGER.debug("Unable to read JDBC metadata.", e);
            } finally {
                safeClose(connection);
            }
            if (database == null) {
                EjbLogger.EJB3_TIMER_LOGGER.jdbcDatabaseDialectDetectionFailed(databaseDialects.toString());
            } else {
                EjbLogger.EJB3_TIMER_LOGGER.debugf("Detect database dialect as '%s'.  If this is incorrect, please specify the correct dialect using the 'database' attribute in your configuration.  Supported database dialect strings are %s", database, databaseDialects);
            }
        } else {
            EjbLogger.EJB3_TIMER_LOGGER.debugf("Database dialect '%s' read from configuration, adjusting it to match the final database valid value.", database);
            database = identifyDialect(database);
            EjbLogger.EJB3_TIMER_LOGGER.debugf("New Database dialect is '%s'.", database);
        }
    }

Check the connection MetaData and driver name to guess which database dialect
to use.

Check the connection MetaData and driver name to guess which database dialect to use .


private String identifyDialect(String name) {
        String unified = null;

        if (name != null) {
            if (name.toLowerCase().contains("postgres")) {
               unified = "postgresql";
            } else if (name.toLowerCase().contains("mysql")) {
                unified = "mysql";
            } else if (name.toLowerCase().contains("mariadb")) {
                unified = "mariadb";
            } else if (name.toLowerCase().contains("db2")) {
                unified = "db2";
            } else if (name.toLowerCase().contains("hsql") || name.toLowerCase().contains("hypersonic")) {
                unified = "hsql";
            } else if (name.toLowerCase().contains("h2")) {
                unified = "h2";
            } else if (name.toLowerCase().contains("oracle")) {
                unified = "oracle";
            }else if (name.toLowerCase().contains("microsoft")) {
                unified = "mssql";
            }else if (name.toLowerCase().contains("jconnect")) {
                unified = "sybase";
            }
         }
        EjbLogger.EJB3_TIMER_LOGGER.debugf("Check dialect for '%s', result is '%s'", name, unified);
        return unified;
    }

Use the given name and check for different database types to have a unified identifier for the dialect

@param name A database name or even a driver name which should include the database name
@return A unified dialect identifier


private void checkDatabase() {
        String loadTimer = sql(LOAD_TIMER);
        Connection connection = null;
        Statement statement = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            //test for the existence of the table by running the load timer query
            connection = dataSource.getConnection();
            if (connection.getTransactionIsolation() < Connection.TRANSACTION_READ_COMMITTED) {
                EjbLogger.EJB3_TIMER_LOGGER.wrongTransactionIsolationConfiguredForTimer();
            }
            preparedStatement = connection.prepareStatement(loadTimer);
            preparedStatement.setString(1, "NON-EXISTENT");
            preparedStatement.setString(2, "NON-EXISTENT");
            preparedStatement.setString(3, "NON-EXISTENT");
            resultSet = preparedStatement.executeQuery();
        } catch (SQLException e) {
            //the query failed, assume it is because the table does not exist
            if (connection != null) {
                try {
                    String createTable = sql(CREATE_TABLE);
                    String[] statements = createTable.split(";");
                    for (final String sql : statements) {
                        try {
                            statement = connection.createStatement();
                            statement.executeUpdate(sql);
                        } finally {
                            safeClose(statement);
                        }
                    }
                } catch (SQLException e1) {
                    EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e1);
                }
            } else {
                EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e);
            }
        } finally {
            safeClose(resultSet);
            safeClose(preparedStatement);
            safeClose(statement);
            safeClose(connection);
        }
    }

Checks whether the database transaction configuration is appropriate
and create the timer table if necessary.

Checks whether the database transaction configuration is appropriate and create the timer table if necessary .


private Date stringAsSchedulerDate(final String date, final String timerId) {
        if (date == null) {
            return null;
        }
        try {
            return new SimpleDateFormat(SCHEDULER_DATE_FORMAT).parse(date);
        } catch (ParseException e) {
            EjbLogger.EJB3_TIMER_LOGGER.scheduleExpressionDateFromTimerPersistenceInvalid(timerId, e.getMessage());
            return null;
        }
    }

Convert the stored date-string from database back to Date

Convert the stored date - string from database back to Date


private void setNodeName(final TimerState timerState, PreparedStatement statement, int paramIndex) throws SQLException {
        if(timerState == TimerState.IN_TIMEOUT || timerState == TimerState.RETRY_TIMEOUT) {
            statement.setString(paramIndex, nodeName);
        } else {
            statement.setNull(paramIndex, Types.VARCHAR);
        }
    }

private void setNodeName ( final TimerState timerState , PreparedStatement statement , int paramIndex ) throws SQLException { if ( timerState == TimerState . IN_TIMEOUT || timerState == TimerState . RETRY_TIMEOUT ) { statement . setString ( paramIndex , nodeName ) ; } else { statement . setNull ( paramIndex , Types . VARCHAR ) ; } }

Set the node name for persistence if the state is IN_TIMEOUT or RETRY_TIMEOUT to show which node is current active for the timer.

Set the node name for persistence if the state is IN_TIMEOUT or RETRY_TIMEOUT to show which node is current active for the timer .


public static void mark(DeploymentUnit unit) {
        unit.putAttachment(MARKER, Boolean.TRUE);
        if (unit.getParent() != null) {
            mark(unit.getParent());
        }
    }

public static void mark ( DeploymentUnit unit ) { unit . putAttachment ( MARKER , Boolean . TRUE ) ; if ( unit . getParent ( ) != null ) { mark ( unit . getParent ( ) ) ; } }

Mark this deployment and the top level deployment as being a weld deployment.

Mark this deployment and the top level deployment as being a weld deployment .


public Object[] readParams(InputStream in) {
        int len = paramReaders.length;
        Object[] params = new Object[len];
        for (int i = 0; i < len; i++) {
            params[i] = paramReaders[i].read(in);
        }
        return params;
    }

public Object [ ] readParams ( InputStream in ) { int len = paramReaders . length ; Object [ ] params = new Object [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { params [ i ] = paramReaders [ i ] . read ( in ) ; } return params ; }

Unmarshals the sequence of method parameters from an input stream.

@param in a CDR input stream
@return an object array with the parameters.

Unmarshals the sequence of method parameters from an input stream .


public void writeRetval(OutputStream out, Object retVal) {
        retvalWriter.write(out, RemoteObjectSubstitutionManager.writeReplaceRemote(retVal));
    }

public void writeRetval ( OutputStream out , Object retVal ) { retvalWriter . write ( out , RemoteObjectSubstitutionManager . writeReplaceRemote ( retVal ) ) ; }

Marshals into an output stream the return value of the method.

@param out    a CDR output stream
@param retVal the value to be written.

Marshals into an output stream the return value of the method .


public void writeException(OutputStream out, Throwable e) {
        int len = excepWriters.length;
        for (int i = 0; i < len; i++) {
            if (excepWriters[i].getExceptionClass().isInstance(e)) {
                excepWriters[i].write(out, e);
                return;
            }
        }
        throw new UnknownException(e);
    }

public void writeException ( OutputStream out , Throwable e ) { int len = excepWriters . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( excepWriters [ i ] . getExceptionClass ( ) . isInstance ( e ) ) { excepWriters [ i ] . write ( out , e ) ; return ; } } throw new UnknownException ( e ) ; }

Marshals into an output stream an exception thrown by the method.

@param out a CDR output stream
@param e   the exception to be written.

Marshals into an output stream an exception thrown by the method .


protected <U> U lookup(Lookup<U> lookup, int start, int depth) {
        int size;
        synchronized (indexes) {
            size = indexes.size();
            for (int i = start; i < depth && i < size; i++) {
                U result = lookup.lookup(indexes.get(i));
                if (result != null)
                    return result;
            }
        }

        if (currentClass == null)
            return null;

        synchronized (indexes) {
            ClassReflectionIndex cri = index.getClassIndex(currentClass);
            indexes.add(cri);
            currentClass = currentClass.getSuperclass();
        }
        return lookup(lookup, size, depth);
    }

protected < U > U lookup ( Lookup < U > lookup , int start , int depth ) { int size ; synchronized ( indexes ) { size = indexes . size ( ) ; for ( int i = start ; i < depth && i < size ; i ++ ) { U result = lookup . lookup ( indexes . get ( i ) ) ; if ( result != null ) return result ; } } if ( currentClass == null ) return null ; synchronized ( indexes ) { ClassReflectionIndex cri = index . getClassIndex ( currentClass ) ; indexes . add ( cri ) ; currentClass = currentClass . getSuperclass ( ) ; } return lookup ( lookup , size , depth ) ; }

Do lazy lookup.

@param lookup the lookup
@param start the start
@param depth the depth
@return reflection index result