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());
}
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()));
}
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;
}
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;
}
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;
}
Aggregations