FileDocCategorySizeDatePackage
JDOCodeGeneratorHelper.javaAPI DocGlassfish v2 API7137Fri May 04 22:34:48 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbc

JDOCodeGeneratorHelper

public class JDOCodeGeneratorHelper extends Object

Fields Summary
private static final ResourceBundle
messages
I18N message handler
Constructors Summary
Methods Summary
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, com.sun.enterprise.deployment.EjbBundleDescriptor bundle)
Create GeneratorException for this message key.

param
key the message key in the bundle.
param
bundle the ejb bundle.
return
GeneratorException.

        return new GeneratorException(I18NHelper.getMessage(
            messages, key,
            bundle.getApplication().getRegistrationName(),
            getModuleName(bundle)));
    
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, com.sun.enterprise.deployment.EjbBundleDescriptor bundle, java.lang.Exception e)
Create GeneratorException for this message key.

param
key the message key in the bundle.
param
bundle the ejb bundle.
param
e the Exception to use for the message.
return
GeneratorException.


        return new GeneratorException(I18NHelper.getMessage(
            messages, key,
            bundle.getApplication().getRegistrationName(),
            getModuleName(bundle), 
            e.getMessage()));
    
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, java.lang.String beanName, com.sun.enterprise.deployment.EjbBundleDescriptor bundle)
Create GeneratorException for this message key and bean name.

param
key the message key in the bundle.
param
bundle the ejb bundle.
return
GeneratorException.


        return new GeneratorException(I18NHelper.getMessage(
            messages, key, beanName,
            bundle.getApplication().getRegistrationName(),
            getModuleName(bundle)));
    
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, java.lang.String beanName, com.sun.enterprise.deployment.EjbBundleDescriptor bundle, java.lang.Exception e)
Create GeneratorException for this message key and bean name.

param
key the message key in the bundle.
param
beanName the CMP bean name that caused the exception.
param
bundle the ejb bundle.
param
e the Exception to use for the message.
return
GeneratorException.


        return createGeneratorException(key, beanName, bundle, e.getMessage());
    
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, java.lang.String beanName, com.sun.enterprise.deployment.EjbBundleDescriptor bundle, java.lang.Exception e, java.lang.StringBuffer buf)
Create GeneratorException for this message key, bean name, and a StringBuffer with validation exceptions.

param
key the message key in the bundle.
param
beanName the CMP bean name that caused the exception.
param
bundle the ejb bundle.
param
e the Exception to use for the message.
param
buf the StringBuffer with validation exceptions.
return
GeneratorException.


        String msg = (buf == null) ?
                e.getMessage() :
                buf.append(e.getMessage()).append('\n").toString();
        return createGeneratorException(key, beanName, bundle, msg);
    
public static com.sun.ejb.codegen.GeneratorExceptioncreateGeneratorException(java.lang.String key, java.lang.String beanName, com.sun.enterprise.deployment.EjbBundleDescriptor bundle, java.lang.String msg)
Create GeneratorException for this message key and bean name.

param
key the message key in the bundle.
param
beanName the CMP bean name that caused the exception.
param
bundle the ejb bundle.
param
msg the message text to append.
return
GeneratorException.


        return new GeneratorException(I18NHelper.getMessage(
            messages, key,
            new Object[] {
                beanName, 
                bundle.getApplication().getRegistrationName(),
                getModuleName(bundle),
                msg}
            ));
    
public static java.lang.StringgetModuleName(com.sun.enterprise.deployment.EjbBundleDescriptor bundle)
Calculate module name from a bundle.

return
module name.


                  
         
        String moduleName = null;
        Application application = bundle.getApplication();
        if (application.isVirtual()) {
            // Stand-alone module is deployed.
            moduleName = application.getRegistrationName();

        } else {
            // Module is deployed as a part of an Application.
            String jarName = bundle.getModuleDescriptor().getArchiveUri();
            int l = jarName.length();

            // Remove ".jar" from the bundle's jar name.
            moduleName = jarName.substring(0, l - 4);

        }

        return moduleName;