Search in sources :

Example 6 with IASEjbExtraDescriptors

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

the class ASEjbIsReadOnlyBean method check.

/**
 * @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 {
        IASEjbExtraDescriptors iasEjbExtraDesc = descriptor.getIASEjbExtraDescriptors();
        String s1 = ("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/is-read-only-bean");
        String isReadOnlyBean = getXPathValue(s1);
        if (isReadOnlyBean != null) {
            if (isReadOnlyBean.equals(new String("true"))) {
                testROBSpecific(descriptor, iasEjbExtraDesc, result);
            } else if (isReadOnlyBean.equals(new String("false"))) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] is-read-only-bean is {0}", new Object[] { new String(isReadOnlyBean) }));
            } else {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB ejb] value [{0}] for is-read-only-bean is incorrect. It can only be true or false", new Object[] { new String(isReadOnlyBean) }));
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] is-read-only-bean Element not defined"));
        }
        if (oneFailed)
            result.setStatus(Result.FAILED);
        else if (oneWarning)
            result.setStatus(Result.WARNING);
    } catch (Exception ex) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create a descriptor object"));
    }
    return result;
}
Also used : IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 7 with IASEjbExtraDescriptors

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

the class ASEjbMDBConnFactory method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    boolean oneWarn = false;
    try {
        IASEjbExtraDescriptors iasEjbExtraDesc = descriptor.getIASEjbExtraDescriptors();
        MdbConnectionFactoryDescriptor mdbConnFacDesc = iasEjbExtraDesc.getMdbConnectionFactory();
        if (mdbConnFacDesc != null) {
            String jndiName = mdbConnFacDesc.getJndiName();
            if (jndiName == null || jndiName.length() == 0) {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB mdb-connection-factory] : jndi-name cannot be an empty string"));
            } else {
                if (jndiName.startsWith("jms/")) {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB mdb-connection-factory] : jndi-name is {0}", new Object[] { jndiName }));
                } else {
                    oneWarn = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB mdb-connection-factory] : jndi-name {0} should start with jms/", new Object[] { jndiName }));
                }
            }
            ResourcePrincipal defPrinci = mdbConnFacDesc.getDefaultResourcePrincipal();
            if (defPrinci != null) {
                String name = defPrinci.getName();
                if (name == null || name.length() == 0) {
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB default-resource-principal] : name cannot be an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB default-resource-principal] : name is {0}", new Object[] { name }));
                }
                String password = defPrinci.getPassword();
                if (password == null || password.length() == 0) {
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning2", "WARNING [AS-EJB default-resource-principal] : password is an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB default-resource-principal] : password is  {0}", new Object[] { password }));
                }
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB mdb-connection-factory] : default-resource-prncipal element is not defined"));
            }
        } else {
            if (descriptor instanceof EjbMessageBeanDescriptor) {
                boolean failed = false;
                int count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter");
                if (count > 0) {
                    String value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/resource-adapter-mid");
                    if (value == null || value.length() == 0) {
                        failed = true;
                    }
                } else {
                    failed = true;
                }
                if (failed) {
                    EjbMessageBeanDescriptor mdbDesc = (EjbMessageBeanDescriptor) descriptor;
                    if (mdbDesc.hasTopicDest() && mdbDesc.hasDurableSubscription()) {
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB ejb] : mdb-connection-factory has to be defined for an MDB with destination-type " + "as Topic and subscription-durability as Durable"));
                    }
                /**
                 *                        else{
                 *                            oneWarn = true;
                 *                            result.warning(smh.getLocalString(getClass().getName()+".warning1",
                 *                                 "WARNING [AS-EJB ejb] : mdb-connection-factory should be defined for a Message Driven Bean"));
                 *                        }
                 */
                }
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB ejb] : mdb-connection-factory element is not defined"));
            }
        }
        if (oneFailed)
            result.setStatus(Result.FAILED);
        else if (oneWarn)
            result.setStatus(Result.WARNING);
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
    return result;
}
Also used : EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) ResourcePrincipal(com.sun.enterprise.deployment.ResourcePrincipal) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) MdbConnectionFactoryDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.MdbConnectionFactoryDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 8 with IASEjbExtraDescriptors

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

the class ASEjbRefreshPeriod method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneWarning = false;
    boolean oneFailed = false;
    boolean isReadOnly = false;
    String refreshPeriod = null;
    try {
        String s1 = ("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/refresh-period-in-seconds");
        refreshPeriod = getXPathValue(s1);
        IASEjbExtraDescriptors iasEjbExtraDesc = descriptor.getIASEjbExtraDescriptors();
        isReadOnly = iasEjbExtraDesc.isIsReadOnlyBean();
        if (refreshPeriod != null) {
            refreshPeriod = refreshPeriod.trim();
            if (refreshPeriod.length() == 0) {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It should be between 0 and " + Integer.MAX_VALUE));
            } else {
                if (!(descriptor instanceof EjbEntityDescriptor && isReadOnly)) {
                    oneWarning = true;
                    result.addWarningDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans."));
                    return result;
                }
                try {
                    int refValue = Integer.parseInt(refreshPeriod);
                    if (refValue < 0 || refValue > Integer.MAX_VALUE) {
                        oneFailed = true;
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB ejb] : refresh-period-in-seconds cannot be greater than " + Integer.MAX_VALUE + " or less than 0"));
                    } else
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] : refresh-period-in-seconds is {0}", new Object[] { new Integer(refValue) }));
                } catch (NumberFormatException nfex) {
                    oneFailed = true;
                    Verifier.debug(nfex);
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It should be between 0 and " + Integer.MAX_VALUE));
                }
            }
        } else {
            if ((descriptor instanceof EjbEntityDescriptor) && (isReadOnly)) {
                oneWarning = true;
                result.addWarningDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans"));
            } else {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : refresh-period-in-seconds is not defined"));
            }
        }
        if (oneWarning)
            result.setStatus(Result.WARNING);
        if (oneFailed)
            result.setStatus(Result.FAILED);
    } catch (Exception ex) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
    return result;
}
Also used : EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 9 with IASEjbExtraDescriptors

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

the class ASEjbBeanPool method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    IASEjbExtraDescriptors ejbJar = descriptor.getIASEjbExtraDescriptors();
    if (ejbJar != null) {
        try {
            beanPool = ejbJar.getBeanPool();
            if (beanPool != null) {
                if (descriptor instanceof EjbSessionDescriptor && ((EjbSessionDescriptor) descriptor).getSessionType().equals(EjbSessionDescriptor.STATEFUL)) {
                    result.addWarningDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB ejb] : bean-pool should be defined for Stateless Session Beans, Entity Beans or Message Driven Beans"));
                } else if (descriptor instanceof EjbMessageBeanDescriptor || (descriptor instanceof EjbSessionDescriptor && ((EjbSessionDescriptor) descriptor).getSessionType().equals(EjbSessionDescriptor.STATELESS)) || descriptor instanceof EjbEntityDescriptor) {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] : bean-pool is correctly defined"));
                }
            } else {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : bean-pool element not defined"));
            }
            return result;
        } catch (Exception ex) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create a beanPool object"));
        }
    } else {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an IASEjbExtraDescriptor object"));
    }
    return result;
}
Also used : EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) EjbMessageBeanDescriptor(com.sun.enterprise.deployment.EjbMessageBeanDescriptor) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) EjbSessionDescriptor(com.sun.enterprise.deployment.EjbSessionDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

IASEjbExtraDescriptors (org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors)9 Result (com.sun.enterprise.tools.verifier.Result)6 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)6 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)3 EjbMessageBeanDescriptor (org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor)2 InvocationInfo (com.sun.ejb.InvocationInfo)1 EjbMessageBeanDescriptor (com.sun.enterprise.deployment.EjbMessageBeanDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)1 SecurityManager (com.sun.enterprise.security.SecurityManager)1 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 RemoteException (java.rmi.RemoteException)1 Iterator (java.util.Iterator)1 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)1 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)1 CreateException (javax.ejb.CreateException)1 EJBException (javax.ejb.EJBException)1