FileDocCategorySizeDatePackage
ConnectorAdminServiceUtils.javaAPI DocGlassfish v2 API6444Fri May 04 22:34:22 BST 2007com.sun.enterprise.connectors

ConnectorAdminServiceUtils

public class ConnectorAdminServiceUtils extends Object implements ConnectorConstants
Util classes common to all connector Services
author
Srikanth P

Fields Summary
Constructors Summary
private ConnectorAdminServiceUtils()

        
    
Methods Summary
public static java.lang.StringgetApplicationName(java.lang.String moduleName)

        if (isEmbeddedConnectorModule(moduleName)) {
            int idx = moduleName.indexOf(
                            ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER);
            return moduleName.substring(0, idx);
        } else { 
            return null;
        }
    
public static java.lang.StringgetConnectorModuleName(java.lang.String moduleName)

        if (isEmbeddedConnectorModule(moduleName)) {
            int idx = moduleName.indexOf(
                            ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER);
            return moduleName.substring(idx+1);
        } else { 
            return moduleName;
        }
    
public static ResourcePrincipalgetDefaultResourcePrincipal(java.lang.String poolName)

        // All this to get the default user name and principal
        ConnectorConnectionPool connectorConnectionPool = null;
        try {
            String jndiNameForPool = getReservePrefixedJNDINameForPool(poolName) ;
            InitialContext ic = new InitialContext();
            connectorConnectionPool =
                    (ConnectorConnectionPool) ic.lookup(jndiNameForPool);
        } catch (NamingException ne ) {
            throw ne;
        }

        ConnectorDescriptorInfo cdi = connectorConnectionPool.
            getConnectorDescriptorInfo();

        Set mcfConfigProperties = cdi.getMCFConfigProperties();
        Iterator mcfConfPropsIter = mcfConfigProperties.iterator();
        String userName = "";
        String password = "";
        while( mcfConfPropsIter.hasNext() ) {
            EnvironmentProperty prop =
            (EnvironmentProperty)mcfConfPropsIter.next();

            if ( prop.getName().toUpperCase().equals("USERNAME") ||
                 prop.getName().toUpperCase().equals("USER") ) {
                userName = prop.getValue();
            } else if ( prop.getName().toUpperCase().equals("PASSWORD") ) {
                password = prop.getValue();
            }
        }

        //Now return the ResourcePrincipal
        return new ResourcePrincipal( userName, password );
               
    
public static java.lang.StringgetOriginalResourceName(java.lang.String reservePrefixedJNDIName)

        String prefix = null;
        if ( reservePrefixedJNDIName.startsWith(ConnectorConstants.POOLS_JNDINAME_PREFIX) ) {
            prefix = ConnectorConstants.POOLS_JNDINAME_PREFIX;
        } else if ( reservePrefixedJNDIName.startsWith(ConnectorConstants.DD_PREFIX) ) {
            prefix = ConnectorConstants.DD_PREFIX;
        } else if ( reservePrefixedJNDIName.startsWith( ConnectorConstants.RESOURCE_JNDINAME_PREFIX) ) {
            prefix = ConnectorConstants.RESOURCE_JNDINAME_PREFIX;
        }
        return (( prefix == null ) ? reservePrefixedJNDIName : reservePrefixedJNDIName.substring(prefix.length()) );
    
private static java.lang.StringgetReservePrefixedJNDIName(java.lang.String prefix, java.lang.String resourceName)

        return prefix + resourceName;
    
public static java.lang.StringgetReservePrefixedJNDINameForDescriptor(java.lang.String moduleName)

        return getReservePrefixedJNDIName(ConnectorConstants.DD_PREFIX, moduleName); 
    
public static java.lang.StringgetReservePrefixedJNDINameForPool(java.lang.String poolName)

        return getReservePrefixedJNDIName(ConnectorConstants.POOLS_JNDINAME_PREFIX, poolName); 
    
public static java.lang.StringgetReservePrefixedJNDINameForResource(java.lang.String moduleName)

        return getReservePrefixedJNDIName(ConnectorConstants.RESOURCE_JNDINAME_PREFIX, moduleName); 
    
public static booleanisEmbeddedConnectorModule(java.lang.String moduleName)

        return (moduleName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) != -1);
    
public static booleanisJMSRA(java.lang.String moduleName)

        return moduleName.equalsIgnoreCase(ConnectorConstants.DEFAULT_JMS_ADAPTER);