Search in sources :

Example 6 with IASEjbCMPEntityDescriptor

use of org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor in project Payara by payara.

the class EjbConversionHelper method applyDefaultUnknownPKClassStrategy.

/**
 * Returns flag whether the mapping conversion should apply the default
 * strategy for dealing with unknown primary key classes. This method will
 * only be called when {@link #generateFields} returns <code>true</code>.
 * @param ejbName The value of the ejb-name element for a bean.
 * @return <code>true</code> to apply the default unknown PK Class Strategy,
 * <code>false</code> otherwise
 */
public boolean applyDefaultUnknownPKClassStrategy(String ejbName) {
    IASEjbCMPEntityDescriptor ejbDesc = (IASEjbCMPEntityDescriptor) ejbDescMap.get(ejbName);
    String keyClassName = ejbDesc.getPrimaryKeyClassName();
    return keyClassName != null && keyClassName.equals(Object.class.getName());
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor)

Example 7 with IASEjbCMPEntityDescriptor

use of org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor in project Payara by payara.

the class MethodHelper method categorizeMethods.

/**
 * Reads all known methods and sorts them by name into specific
 * Collections for further processing.
 */
protected void categorizeMethods() {
    IASEjbCMPEntityDescriptor cmpDescriptor = (IASEjbCMPEntityDescriptor) getDescriptor();
    super.categorizeMethods();
    // replace the finders and selectors with ias specific info
    setFinders(getListForCollection(cmpDescriptor.getFinders()));
    setSelectors(getListForCollection(cmpDescriptor.getSelectors()));
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor)

Example 8 with IASEjbCMPEntityDescriptor

use of org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor in project Payara by payara.

the class MethodHelper method isQueryPrefetchEnabled.

/**
 * Returns <code>true</code> if prefetch is enabled for the specified
 * method, <code>false</code> otherwise. Prefetch is enabled by default.
 * @param method the java.lang.reflect.Method object used to find the
 * prefetch setting.
 * @return a boolean representing the prefetch setting
 */
public boolean isQueryPrefetchEnabled(Method method) {
    boolean enabled = true;
    QueryDescriptor queryDescriptor = getQueryDescriptor(method);
    if (queryDescriptor != null) {
        IASEjbCMPEntityDescriptor cmpDescriptor = (IASEjbCMPEntityDescriptor) getDescriptor();
        PrefetchDisabledDescriptor pdDescriptor = cmpDescriptor.getPrefetchDisabledDescriptor();
        if (pdDescriptor != null) {
            MethodDescriptor methodDescriptor = queryDescriptor.getQueryMethodDescriptor();
            enabled = !pdDescriptor.isPrefetchDisabledFor(methodDescriptor);
        }
    }
    return enabled;
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) PrefetchDisabledDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.PrefetchDisabledDescriptor) QueryDescriptor(org.glassfish.ejb.deployment.descriptor.QueryDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 9 with IASEjbCMPEntityDescriptor

use of org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor in project Payara by payara.

the class EjbQLFromCmpEntityDescriptor method check.

/**
 * Implements the check on EJB QL's syntax and semantics.
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        if (descriptor instanceof IASEjbCMPEntityDescriptor) {
            Collection col = null;
            if (getVerifierContext().getJDOException() != null) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: Exception [ {0} ] while initialising JDO code generator.", new Object[] { getVerifierContext().getJDOException().getMessage() }));
                return result;
            } else {
                try {
                    JDOCodeGenerator jdc = getVerifierContext().getJDOCodeGenerator();
                    col = jdc.validate((IASEjbCMPEntityDescriptor) descriptor);
                } catch (Exception ex) {
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", new Object[] { ex.getMessage() }));
                    return result;
                }
            }
            if (col.isEmpty()) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "Syntax and Semantics of EJBQL Queries (if any) are correct."));
            } else {
                // collect all the EJBQL errors
                String allErrors = null;
                Iterator it = col.iterator();
                while (it.hasNext()) {
                    Exception e = (Exception) it.next();
                    if (e instanceof EJBQLException) {
                        allErrors = e.getMessage() + "\n\n";
                    }
                }
                if (allErrors != null) {
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".parseError", "Error: Entity bean [ {0} ] has the following EJBQL error(s) [ {1} ].", new Object[] { descriptor.getEjbClassName(), "\n" + allErrors }));
                } else {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "Syntax and Semantics of EJBQL Queries (if any) are correct."));
                }
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "Not applicable: Test only applies to container managed EJBs"));
        }
    } catch (Exception e) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", new Object[] { e.getMessage() }));
    }
    return result;
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) JDOCodeGenerator(com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator) Iterator(java.util.Iterator) EJBQLException(com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException) Collection(java.util.Collection) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) EJBQLException(com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException) Result(com.sun.enterprise.tools.verifier.Result)

Example 10 with IASEjbCMPEntityDescriptor

use of org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor in project Payara by payara.

the class ASEjbCMP method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        if (descriptor instanceof IASEjbCMPEntityDescriptor) {
            IASEjbCMPEntityDescriptor cmpBean = (IASEjbCMPEntityDescriptor) descriptor;
            String mappingProps = cmpBean.getMappingProperties();
            if (mappingProps == null) {
                oneWarning = true;
                addWarningDetails(result, compName);
                result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB cmp] : mapping-properties Element is not defined"));
            } else {
                if (mappingProps.length() == 0) {
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB cmp] : mapping-properties field must contain a vaild non-empty value"));
                } else {
                    // 4690436
                    // File f = Verifier.getArchiveFile(descriptor.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri());
                    JarFile jarFile = null;
                    ZipEntry deploymentEntry = null;
                    // jarFile = new JarFile(f);
                    if (jarFile != null)
                        deploymentEntry = jarFile.getEntry(mappingProps);
                    if (deploymentEntry != null) {
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB cmp] : mapping-properties file is {0}", new Object[] { mappingProps }));
                    } else {
                        addErrorDetails(result, compName);
                        // invalid entry
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB cmp] : mapping-properties field must contain a vaild non-empty value"));
                    }
                }
            }
            try {
                boolean oneoneCmp = cmpBean.getCMPVersion() == EjbCMPEntityDescriptor.CMP_1_1;
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB cmp] : is-one-one-cmp is {0}", new Object[] { new Boolean(oneoneCmp) }));
            } catch (Exception ex) {
                oneWarning = true;
                addWarningDetails(result, compName);
                result.warning(smh.getLocalString(getClass().getName() + ".warning1", "WARNING [AS-EJB cmp] : is-one-one-cmp Element is not defined"));
            }
            try {
                // EXCEPTION is thrown here as getOneOneFinders() internally uses queryPArser which is null. Exception as:
                // Apr 4, 2003 11:18:22 AM com.sun.enterprise.deployment.IASEjbCMPEntityDescriptor getOneOneFinder
                Map finders = cmpBean.getOneOneFinders();
                if (finders != null) {
                    testFinders(finders, result);
                } else {
                    oneWarning = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning2", "WARNING [AS-EJB cmp] : one-one-finders Element is not defined"));
                }
            } catch (Exception ex) {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB cmp] : getOneOneFinders Failed.", new Object[] { cmpBean }));
            }
            if (oneFailed) {
                result.setStatus(Result.FAILED);
            } else {
                if (oneWarning)
                    result.setStatus(Result.WARNING);
            }
        } else {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB cmp] : {0} is not a CMP Entity Bean.", new Object[] { descriptor.getName() }));
        }
    } catch (Exception ex) {
        oneFailed = true;
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
    return result;
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) ZipEntry(java.util.zip.ZipEntry) JarFile(java.util.jar.JarFile) Map(java.util.Map) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

IASEjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor)10 Iterator (java.util.Iterator)4 Result (com.sun.enterprise.tools.verifier.Result)3 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)3 JDOCodeGenerator (com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator)3 EJBQLException (com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException)2 Collection (java.util.Collection)2 Map (java.util.Map)2 Application (com.sun.enterprise.deployment.Application)1 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 XMLElement (com.sun.enterprise.deployment.node.XMLElement)1 EjbRefNode (com.sun.enterprise.deployment.node.runtime.EjbRefNode)1 MessageDestinationRefNode (com.sun.enterprise.deployment.node.runtime.MessageDestinationRefNode)1 ResourceEnvRefNode (com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode)1 ResourceRefNode (com.sun.enterprise.deployment.node.runtime.ResourceRefNode)1 RuntimeDescriptorNode (com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode)1