public ArrayList<String> generateBindings(String interfaceName,
                                              String specificBindingName,
                                              boolean
                                              generateDisambiguatedSimpleBindingNames)
                    throws NameAlreadyBoundException // d457053.1
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "generateBindings: " + interfaceName + ", " +
                         specificBindingName + ", " + generateDisambiguatedSimpleBindingNames);

        // Module version is a 3.0 or later.
        ArrayList<String> jndiNamesToBind;

        if (specificBindingName == null)
        {
            // The simple-binding-name is obtained from the BeanMetaData and
            // is allowed to be null when default binding is desired.
            String simpleBindingName = ivHomeRecord.getBeanMetaData().simpleJndiBindingName;
            if (simpleBindingName == null)
            {
                // Since neither a specific or simple binding name was specifed
                // generate the Short and Long form Default bindings.
                jndiNamesToBind = generateDefaultEjbBindings(interfaceName);
            }
            else
            {
                // We have a simple binding name.
                // In the case where ambigous simple binding names are possible
                // (for instance multiple busineess interfaces or presence of
                // homes and business interfaces), disambiguate them by appending
                // the interfaceName to the end of the binding name.
                if (generateDisambiguatedSimpleBindingNames)
                {
                    // Before disambiguating by adding #<interface>, create an
                    // AmbiguousEJBReferenceException for the ambiguous form
                    // of the simple binding name, and add it to the list to be
                    // bound later for this EJB. Also add to the EJB Context
                    // map, prepending # to the interface name, so that it will
                    // be unbound during uninstall app.
                    // Only add the AmbiguousReference for the first interface
                    // processed for this simple-binding-name.              d457053.1
                    Reference ambiguousRef = ivEjbContextAmbiguousMap.get(simpleBindingName);
                    if (ambiguousRef == null)
                    {
                        addAmbiguousSimpleBindingName(simpleBindingName);
                        addToServerContextBindingMap(interfaceName, simpleBindingName);
                        ivEjbContextBindingMap.put("#" + interfaceName, simpleBindingName);
                    }

                    StringBuilder sb = new StringBuilder(simpleBindingName);
                    sb.append("#").append(interfaceName);
                    simpleBindingName = sb.toString();
                }

                // Add the name to the list to return, the map for this ejb in the
                // correct context (local/remote) and the server wide map.
                jndiNamesToBind = new ArrayList<String>(1);
                jndiNamesToBind.add(simpleBindingName);
                addToServerContextBindingMap(interfaceName, simpleBindingName);
                ivEjbContextBindingMap.put(interfaceName, simpleBindingName);

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "using simple binding : " + simpleBindingName);
            }
        }
        else
        {
            // A specific binding name has been specified, use it.
            // Add the name to the list to return, the map for this ejb in the
            // correct context (local/remote) and the server wide map.
            jndiNamesToBind = new ArrayList<String>(1);
            jndiNamesToBind.add(specificBindingName);
            addToServerContextBindingMap(interfaceName, specificBindingName);
            ivEjbContextBindingMap.put(interfaceName, specificBindingName);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "using specific bindings : " + specificBindingName);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "generateBindings: " + jndiNamesToBind);

        return jndiNamesToBind;
    }
public ArrayList < String > generateBindings ( String interfaceName , String specificBindingName , boolean generateDisambiguatedSimpleBindingNames ) throws NameAlreadyBoundException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "generateBindings: " + interfaceName + ", " + specificBindingName + ", " + generateDisambiguatedSimpleBindingNames ) ; ArrayList < String > jndiNamesToBind ; if ( specificBindingName == null ) { String simpleBindingName = ivHomeRecord . getBeanMetaData ( ) . simpleJndiBindingName ; if ( simpleBindingName == null ) { jndiNamesToBind = generateDefaultEjbBindings ( interfaceName ) ; } else { if ( generateDisambiguatedSimpleBindingNames ) { Reference ambiguousRef = ivEjbContextAmbiguousMap . get ( simpleBindingName ) ; if ( ambiguousRef == null ) { addAmbiguousSimpleBindingName ( simpleBindingName ) ; addToServerContextBindingMap ( interfaceName , simpleBindingName ) ; ivEjbContextBindingMap . put ( "#" + interfaceName , simpleBindingName ) ; } StringBuilder sb = new StringBuilder ( simpleBindingName ) ; sb . append ( "#" ) . append ( interfaceName ) ; simpleBindingName = sb . toString ( ) ; } jndiNamesToBind = new ArrayList < String > ( 1 ) ; jndiNamesToBind . add ( simpleBindingName ) ; addToServerContextBindingMap ( interfaceName , simpleBindingName ) ; ivEjbContextBindingMap . put ( interfaceName , simpleBindingName ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "using simple binding : " + simpleBindingName ) ; } } else { jndiNamesToBind = new ArrayList < String > ( 1 ) ; jndiNamesToBind . add ( specificBindingName ) ; addToServerContextBindingMap ( interfaceName , specificBindingName ) ; ivEjbContextBindingMap . put ( interfaceName , specificBindingName ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "using specific bindings : " + specificBindingName ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "generateBindings: " + jndiNamesToBind ) ; return jndiNamesToBind ; }
This is main method utilized by the EJBContainer for picking and
generating EJB Binding Names. <p>

The algortithm is:

<ul>
<li> If a non-null specificBindingName is passed, it will be used.
<li> If a null specificBindingName is specified and a non-null
simpleBindingName is found, the simpleBindName is used.
<li> If neither a specificBindingName or simpleBindingName is specified
(both null), then Short and Long form Default Names are generated.
<li> If both the Short and Long form Default Names are generated, then
it is required that the Long form occupy the first entry in the
ArrayList.
</ul>

It is a configuration error to specify both a specificBindingName and a
simpleBindingName. This condition is detected in the EJBMDOrchestrator
and this method assumes to never be called with this case.

@param interfaceName A String representing the interface class name.
@param specificBindingName A String representing a specific-binding-name,
null means no specific binding name specified.
@param generateDisambiguatedSimpleBindingNames A boolean, which when true
will cause any generated simple binding names to be
constructed to include "#<interfaceName>" at the end
of the binding name.

@return an ArrayList of Strings representing the names to be used by the
EJBContainer for binding into the jndiNameSpace.

@throws NameAlreadyBoundException if the binding name being added
has previously been added.