FileDocCategorySizeDatePackage
DeploymentHelper.javaAPI DocGlassfish v2 API7989Fri May 04 22:35:04 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.ejb

DeploymentHelper

public class DeploymentHelper extends Object
This class is used for static method invocations to avoid unnecessary registration requirements to use EJBHelper and/or CMPHelper from deploytool, verifier, or any other stand-alone client.

Fields Summary
private static final String
DEFAULT_NAME
Default DDL name prefix. Need to have something to avoid generating hidden names when a suffix is added to an empty string. E.g. .dbschema name can be difficult to find, while default.dbschema will signal that the default had been used.
private static final ResourceBundle
messages
I18N message handler
private static com.sun.jdo.spi.persistence.utility.logging.Logger
logger
The logger
Constructors Summary
Methods Summary
public static java.sql.ConnectiongetConnection(java.lang.String name)
Get a Connection from the resource specified by the JNDI name of a CMP resource. This connection is aquired from a special PM resource which allows to use its connections outside of a business method invocation. The deployment processing is required to use only those connections.

param
name JNDI name of a cmp-resource for the connection.
return
a Connection.
throws
JDOFatalUserException if name cannot be looked up, or we cannot get a connection based on the name.
throws
SQLException if can not get a Connection.

        if (logger.isLoggable(logger.FINE)) {
            logger.fine("ejb.DeploymentHelper.getconnection", name); //NOI18N
        }
        return ConnectorRuntime.getRuntime().getConnection(name);
    
public static java.lang.StringgetDDLNamePrefix(java.lang.Object info)
Returns name prefix for DDL files extracted from the info instance by the Sun-specific code.

param
info the instance to use for the name generation.
return
name prefix as String.


                                               
          
        StringBuffer rc = new StringBuffer();

        if (info instanceof BundleDescriptor) {
            BundleDescriptor bundle = (BundleDescriptor)info;
            rc.append(bundle.getApplication().getRegistrationName());

            Application application = bundle.getApplication();
            if (!application.isVirtual()) {
                String modulePath = bundle.getModuleDescriptor().getArchiveUri();
                int l = modulePath.length();

                // Remove ".jar" from the module's jar name.
                rc.append(DatabaseConstants.NAME_SEPARATOR).
                    append(modulePath.substring(0, l - 4));
            }

        } // no other option is available at this point.

        return (rc.length() == 0)? DEFAULT_NAME : rc.toString();
    
private static voidhandleUnexpectedInstance(java.lang.String name, java.lang.Object value)
Create a RuntimeException for unexpected instance returned from JNDI lookup.

param
name the JNDI name that had been looked up.
param
value the value returned from the JNDI lookup.
throws
JDOFatalUserException.

        RuntimeException e = new JDOFatalUserException(
                I18NHelper.getMessage(messages,
                        "ejb.jndi.unexpectedinstance", //NOI18N
                        name, value.getClass().getName()));
        logger.severe(e.toString());
 
        throw e;
 
    
public static booleanisJavaToDatabase(com.sun.enterprise.deployment.EjbBundleDescriptor bundle)
Returns javatodb flag for this EjbBundleDescriptor

param
bundle a EjbBundleDescriptor
return
true if there is a property entry associated with the corresponding cmp-resource element, which contains "true" as the value for the DatabaseConstants.JAVA_TO_DB_FLAG key.

        Properties userPolicy = bundle.getCMPResourceReference()
                .getSchemaGeneratorProperties();
        return isJavaToDatabase(userPolicy);
    
public static booleanisJavaToDatabase(java.util.Properties prop)
Returns boolean value for the DatabaseConstants.JAVA_TO_DB_FLAG flag in this Properties object.

param
prop a Properties object where flag is located
return
true if there is a property value that contains "true" as the value for the DatabaseConstants.JAVA_TO_DB_FLAG key.

        if (prop != null) {
            String value = prop.getProperty(DatabaseConstants.JAVA_TO_DB_FLAG);
            if (! StringHelper.isEmpty(value)) {
                 if (logger.isLoggable(Logger.FINE))
                     logger.fine(DatabaseConstants.JAVA_TO_DB_FLAG + " property is set."); // NOI18N
                 return Boolean.valueOf(value).booleanValue();
            }
        }
        return false;