use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.
the class CheckConfigPropertyType method check.
/**
* <p>
* Properties names defined in the resource adapter config-propery should
* be of an acceptable type
* </p>
*
* @paramm descriptor deployment descriptor for the rar file
* @return result object containing the result of the individual test
* performed
*/
public Result check(ConnectorDescriptor descriptor) {
boolean oneFailed = false;
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
// Set properties = descriptor.getConfigProperties();
ConnectionDefDescriptor desc = descriptor.getConnectionDefinitionByCFType(null, true);
Set properties = desc.getConfigProperties();
if (properties.size() != 0) {
Iterator iterator = properties.iterator();
// HashSet hs = new HashSet();
while (iterator.hasNext()) {
EnvironmentProperty ep = (EnvironmentProperty) iterator.next();
String type = ep.getType();
if (type == null) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".notdefined", "Error: The configuration property named [ {0} ] has no type ", new Object[] { ep.getName() }));
return result;
}
Class typeClass = null;
// is it loadable ?
try {
typeClass = Class.forName(type);
} catch (Throwable t) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".nonexist", "Error: The type [ {0} ] of the configuration property named [ {1} ] cannot be loaded", new Object[] { ep.getType(), ep.getName() }));
return result;
}
boolean allowedType = false;
for (int i = 0; i < allowedTypes.length; i++) {
if (allowedTypes[i].equals(typeClass)) {
allowedType = true;
break;
}
}
if (!allowedType) {
oneFailed = true;
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The type [ {0} ] for the configuration property named [ {1} ] is not allowed", new Object[] { ep.getType(), ep.getName() }));
return result;
}
}
// for failure, result has been set before
if (!oneFailed) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all properties have an allowed type"));
}
} else {
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "Not Applicable: There are no config-property element defined"));
}
return result;
}
use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.
the class CheckConnectionFactoryImplReferenceable method check.
/**
* <p>
* Test for each connection-definition, that "connectionfactory-impl-class"
* implements javax.resource.Referenceable
* </p>
*
* @param descriptor deployment descriptor for the rar file
* @return result object containing the result of the individual test
* performed
*/
public Result check(ConnectorDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
// test NA for inboundRA
if (!descriptor.getOutBoundDefined()) {
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA", "Resource Adapter does not provide outbound communication"));
return result;
}
OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
if (outboundRA == null) {
return null;
}
boolean oneFailed = false;
Set connDefs = outboundRA.getConnectionDefs();
Iterator iter = connDefs.iterator();
while (iter.hasNext()) {
ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
String connectionImpl = connDefDesc.getConnectionFactoryImpl();
Class implClass = null;
try {
implClass = Class.forName(connectionImpl, false, getVerifierContext().getClassLoader());
} catch (ClassNotFoundException e) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".nonexist", "Error: The class [ {0} ] as defined under connectionfactory-impl-class in the deployment descriptor does not exist", new Object[] { connectionImpl }));
return result;
}
if (!isImplementorOf(implClass, "javax.resource.Referenceable")) {
oneFailed = true;
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: connectionfactory-impl-class [ {0} ] does not implement javax.resource.Referenceable", new Object[] { implClass.getName() }));
return result;
}
}
if (!oneFailed) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all connectionfactory-impl-class implement javax.resource.Referenceable"));
}
return result;
}
use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.
the class ActiveResourceAdapterImpl method createDefaultConnectorResources.
/**
* Creates default connector resource
*
* @throws ConnectorRuntimeException when unable to create connector resources
*/
protected void createDefaultConnectorResources() throws ConnectorRuntimeException {
for (ConnectionDefDescriptor descriptor : connectionDefs_) {
String connectionDefName = descriptor.getConnectionFactoryIntf();
String resourceName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
String poolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
PoolInfo poolInfo = new PoolInfo(poolName);
ResourceInfo resourceInfo = new ResourceInfo(resourceName);
connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
desc_.addDefaultResourceName(resourceName);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Created default connector resource [ " + resourceName + " ] ");
}
}
}
use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.
the class ActiveResourceAdapterImpl method deleteDefaultConnectorConnectionPools.
/**
* Deletes the default connector connection pools.
*/
protected void deleteDefaultConnectorConnectionPools() {
for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
String resourceJndiName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
try {
PoolInfo poolInfo = new PoolInfo(resourceJndiName);
connectorRuntime_.deleteConnectorConnectionPool(poolInfo);
} catch (ConnectorRuntimeException cre) {
_logger.log(Level.WARNING, "rar.undeployment.default_pool_delete_fail", resourceJndiName);
}
}
}
use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.
the class ActiveResourceAdapterImpl method deleteDefaultConnectorResources.
/**
* Deletes the default connector resources.
*/
protected void deleteDefaultConnectorResources() {
for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
String resourceJndiName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
try {
ResourceInfo resourceInfo = new ResourceInfo(resourceJndiName);
connectorRuntime_.deleteConnectorResource(resourceInfo);
} catch (ConnectorRuntimeException cre) {
_logger.log(Level.WARNING, "rar.undeployment.default_resource_delete_fail", resourceJndiName);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Error while trying to delete the default connector resource", cre);
}
}
}
}
Aggregations