use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class ASEjbRRefJndiName method check.
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFailed = false;
try {
Set resRef = descriptor.getResourceReferenceDescriptors();
if (!(resRef.isEmpty())) {
Iterator it = resRef.iterator();
while (it.hasNext()) {
ResourceReferenceDescriptor resDesc = ((ResourceReferenceDescriptor) it.next());
String refName = resDesc.getName();
String refJndiName = resDesc.getJndiName();
String type = resDesc.getType();
if (refJndiName == null || refJndiName.trim().equals("")) {
oneFailed = true;
result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB resource-ref]: jndi-name is not a non empty string"));
}
/* else //Fix for bug id 5018617
{
if(type.indexOf("javax.jms")>-1) //jms resource
{
if(refJndiName.startsWith("jms/")) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName()+".passed1",
"PASSED [AS-EJB resource-ref] : jndi-name {0} is valid", new Object[]{refJndiName}));
}
else
{
oneWarning = true;
addWarningDetails(result, compName);
result.warning(smh.getLocalString(getClass().getName()+".warning1",
"WARNING [AS-EJB resource-ref] : jndi-name is \"{0}\" for resource type \"{1}\"." +
"The preferred jndi-name for JMS resources should start with jms/",
new Object[]{refJndiName,type}));
}
}
else if(type.indexOf("javax.sql")>-1) //jdbc resource
{
if(refJndiName.startsWith("jdbc/")) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName()+".passed1",
"PASSED [AS-EJB resource-ref] : jndi-name {0} is valid", new Object[]{refJndiName}));
}
else
{
oneWarning = true;
addWarningDetails(result, compName);
result.warning(smh.getLocalString(getClass().getName()+".warning2",
"WARNING [AS-EJB resource-ref] : jndi-name is \"{0}\" for resource type \"{1}\"." +
"The preferred jndi-name for JDBC resources should start with jdbc/",
new Object[]{refJndiName,type}));
}
}
else if(type.indexOf("java.net")>-1) //url resource
{
if(refJndiName.startsWith("http://"))//FIX should it start with http:// or url/http://
{
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName()+".passed1",
"PASSED [AS-EJB resource-ref] : jndi-name {0} is valid", new Object[]{refJndiName}));
}
else
{
oneWarning = true;
addWarningDetails(result, compName);
result.warning(smh.getLocalString(getClass().getName()+".warning3",
"WARNING [AS-EJB resource-ref] : jndi-name is \"{0}\" for resource type \"{1}\". " +
"The preferred jndi-name for URL resources should start with a url",
new Object[]{refJndiName,type}));
}
}
else if(type.indexOf("javax.mail")>-1) //jms resource
{
if(refJndiName.startsWith("mail/")) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName()+".passed1",
"PASSED [AS-EJB resource-ref] : jndi-name {0} is valid", new Object[]{refJndiName}));
}
else
{
oneWarning = true;
addWarningDetails(result, compName);
result.warning(smh.getLocalString(getClass().getName()+".warning4",
"WARNING [AS-EJB resource-ref] : jndi-name is \"{0}\" for resource type \"{1}\"." +
"The preferred jndi-name for MAIL resources should start with mail/",
new Object[]{refJndiName,type}));
}
}
else
{
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName()+".passed1","PASSED [AS-EJB resource-ref]: jndi-name {0} is valid",new Object[]{refJndiName}));
}
}*/
}
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB] : {0} Does not define any resource-ref Elements", new Object[] { descriptor.getName() }));
return result;
}
} catch (Exception ex) {
oneFailed = true;
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create the descriptor object"));
return result;
}
/*if(oneWarning)
result.setStatus(Result.WARNING);*/
if (oneFailed)
result.setStatus(Result.FAILED);
else {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB resource-ref]: jndi name is specified correctly for the resource-references with in the application", new Object[] {}));
}
return result;
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class ASEjbResRef method check.
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
Set resRef = descriptor.getResourceReferenceDescriptors();
boolean oneFailed = false;
if (!(resRef.isEmpty())) {
Iterator it = resRef.iterator();
while (it.hasNext()) {
ResourceReferenceDescriptor resDesc = (ResourceReferenceDescriptor) it.next();
String refName = resDesc.getName();
try {
descriptor.getResourceReferenceByName(refName);
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB resource-ref] : res-ref-name {0} is verified with ejb-jar.xml", new Object[] { refName }));
} catch (IllegalArgumentException iaex) {
Verifier.debug(iaex);
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB resource-ref] : The res-ref-name {0} is not defined in ejb-jar.xml for this bean", new Object[] { refName }));
}
}
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "{0} Does not define any resource-ref Elements", new Object[] { descriptor.getName() }));
}
return result;
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class EjbResAuthElement method check.
/**
* The resource-ref element res-auth subelement must be "Application" or
* "Container".
*
* @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();
boolean oneFailed = false;
if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
for (Iterator itr = descriptor.getResourceReferenceDescriptors().iterator(); itr.hasNext(); ) {
ResourceReferenceDescriptor nextResourceReference = (ResourceReferenceDescriptor) itr.next();
// "Container".
if ((nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.APPLICATION_AUTHORIZATION)) || (nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.CONTAINER_AUTHORIZATION))) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Resource-ref element res-auth sub-element value [ {0} ] is valid within bean [ {1} ]", new Object[] { nextResourceReference.getAuthorization(), descriptor.getName() }));
} else {
oneFailed = true;
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: Resource-ref element res-auth sub-element value [ {0} ] is not valid within bean [ {1} ]", new Object[] { nextResourceReference.getAuthorization(), descriptor.getName() }));
}
}
if (!oneFailed) {
result.setStatus(Result.PASSED);
} else {
result.setStatus(Result.FAILED);
}
} else {
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no resource reference elements defined within this bean [ {0} ]", new Object[] { descriptor.getName() }));
}
return result;
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method combineResourceReferenceDescriptors.
/**
* @param env
*/
@Override
protected void combineResourceReferenceDescriptors(JndiNameEnvironment env) {
for (Object oresRef : env.getResourceReferenceDescriptors()) {
ResourceReferenceDescriptor resRef = (ResourceReferenceDescriptor) oresRef;
ResourceReferenceDescriptor rrd = _getResourceReferenceByName(resRef.getName());
if (rrd != null) {
combineInjectionTargets(rrd, resRef);
} else {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictResourceReference()) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictresourceref", "There are more than one resource references defined in web fragments with the same name, but not overrided in web.xml"));
} else {
addResourceReferenceDescriptor(resRef);
}
}
}
}
Aggregations