TxMapUpdateProviderpublic class TxMapUpdateProvider extends Object implements com.sun.xml.ws.policy.jaxws.spi.PolicyMapUpdateProviderFrom CMT EJB methods generate wsdl:binding/wsdl:operations with semantically equivalent WS-AT Policy Assertion(s).
Known limitation: not accounting for ejb deployment descriptor, only working off of TransactionAttribute annotations. |
Fields Summary |
---|
private static final TxLogger | logger | private static boolean | nonJavaEEContainer | private static final WsatPolicyAssertion | AT_ASSERTION_OPTIONAL | private static final WsatPolicyAssertion | AT_ASSERTION_REQUIRED | private static final WsatPolicyAssertion | AT_ALWAYS_CAPABILITY_PA |
Methods Summary |
---|
private static com.sun.xml.ws.policy.Policy | createATPolicy(java.lang.String id, com.sun.xml.ws.tx.common.TxMapUpdateProvider$WsatPolicyAssertion atpa)
return createATPolicy(id, atpa, null);
| private static com.sun.xml.ws.policy.Policy | createATPolicy(java.lang.String id, com.sun.xml.ws.tx.common.TxMapUpdateProvider$WsatPolicyAssertion pa1, com.sun.xml.ws.tx.common.TxMapUpdateProvider$WsatPolicyAssertion pa2)
final ArrayList<AssertionSet> assertionSets = new ArrayList<AssertionSet>(1);
final int numAssertions = (pa2 == null ? 1 : 2);
final ArrayList<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>(numAssertions);
assertions.add(pa1);
if (pa2 != null) {
assertions.add(pa2);
}
assertionSets.add(AssertionSet.createAssertionSet(assertions));
return Policy.createPolicy(null, id, assertionSets);
| private com.sun.xml.ws.policy.Policy | mapTransactionAttribute2WSATPolicy(java.lang.String id, com.sun.xml.ws.tx.common.TransactionAnnotationProcessor.TransactionAttributeType txnAttr)Pass in what the effective transaction attribute for a given Container Manager Transaction EJB method and return the
semantically closest WS-AT policy assertion.
This is best match between Java EE Transaction Attribute and WS-AT Policy Assertion.
There are a number of differences between them.
switch (txnAttr) {
case NOT_SUPPORTED:
case NEVER: // ws-at does not require exception thrown if txn propagated with no assertion.
// no ws-at policy assertion on wsdl:binding/wsdl:operation is equivalent of no
// claim.
return null;
case MANDATORY:
return createATPolicy(id, AT_ASSERTION_REQUIRED);
case SUPPORTS:
return createATPolicy(id, AT_ASSERTION_OPTIONAL);
case REQUIRES_NEW:
return createATPolicy(id, AT_ALWAYS_CAPABILITY_PA);
case REQUIRED:
return createATPolicy(id, AT_ASSERTION_OPTIONAL, AT_ALWAYS_CAPABILITY_PA);
default:
return null;
}
| public void | update(com.sun.xml.ws.policy.PolicyMapExtender policyMapMutator, com.sun.xml.ws.policy.PolicyMap policyMap, com.sun.xml.ws.api.model.SEIModel model, com.sun.xml.ws.api.WSBinding wsBinding)Update policy map with operation scope of correct ws-at policy assertions.
Only looking for this for java to wsdl at tool time.
final String METHOD_NAME = "update";
if (nonJavaEEContainer) {
return;
}
// For each method of a CMT EJB, map its effective javax.ejb.TransactionAttribute to semantically equivalent
// ws-at policy assertion.
if (model != null) {
final Collection<? extends JavaMethod> methods = model.getJavaMethods();
Class CMTEJB = null;
TransactionAttributeType classDefaultTxnAttr = null;
for (JavaMethod method : methods) {
if (CMTEJB == null) {
boolean isCMTEJB = false;
final Class theClass = method.getSEIMethod().getDeclaringClass();
try {
isCMTEJB = TransactionAnnotationProcessor.isContainerManagedEJB(theClass);
} catch (NoClassDefFoundError e) {
// running in a container that does not support EJBs; terminate processing of EJB annotations
nonJavaEEContainer = true;
logger.info(METHOD_NAME, LocalizationMessages.NON_EE_CONTAINER_2005(e.getLocalizedMessage()));
return;
}
if (isCMTEJB) {
// perform class level caching of info
CMTEJB = theClass;
classDefaultTxnAttr = TransactionAnnotationProcessor.getTransactionAttributeDefault(theClass);
} else {
// not a CMT EJB, no transaction attributes to look for; just return
return;
}
}
// we have a CMT EJB. Map its transaction attribute to proper ws-at policy assertion.
final TransactionAttributeType txnAttr =
TransactionAnnotationProcessor.getEffectiveTransactionAttribute(method.getSEIMethod(), classDefaultTxnAttr);
final String policyId = model.getBoundPortTypeName().getLocalPart() + "_" + method.getOperationName() + "_WSAT_Policy";
final Policy policy = mapTransactionAttribute2WSATPolicy(policyId, txnAttr);
if (policy != null) {
// insert ws-at policy assertion in operation scope into policyMapMutator
final PolicyMapKey operationKey =
PolicyMap.createWsdlOperationScopeKey(model.getServiceQName(),
model.getPortName(), new QName(model.getTargetNamespace(), method.getOperationName()));
final PolicySubject generatedWsatPolicySubject = new PolicySubject(method, policy);
if (logger.isLogging(Level.FINE)) {
logger.fine(METHOD_NAME,
LocalizationMessages.ADD_AT_POLICY_ASSERTION_2007(
model.getPortName().toString(),
method.getOperationName(),
policy.toString(),
txnAttr.toString(),
CMTEJB.getName(),
method.getMethod().getName()));
} else {
logger.info(METHOD_NAME,
LocalizationMessages.ADD_AT_POLICY_ASSERTION_2007(
model.getPortName().toString(),
method.getOperationName(),
policy.getId(),
txnAttr.toString(),
CMTEJB.getName(),
method.getMethod().getName()));
}
policyMapMutator.putOperationSubject(operationKey, generatedWsatPolicySubject);
}
} // for each method in CMT EJB
}
|
|