Skip to content

Commit

Permalink
Merge pull request #6953 from stuartwdouglas/method-intf
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Nov 17, 2014
2 parents 3e0e187 + 7b8fda5 commit 227751f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 3 deletions.
Expand Up @@ -42,6 +42,7 @@
import org.jboss.as.ee.component.ComponentConfiguration;
import org.jboss.as.ee.component.ViewConfiguration;
import org.jboss.as.ee.component.ViewDescription;
import org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription;
import org.jboss.as.ejb3.deployment.ApplicationExceptions;
import org.jboss.as.ejb3.remote.EJBRemoteTransactionsRepository;
import org.jboss.as.ejb3.security.EJBSecurityMetaData;
Expand Down Expand Up @@ -241,9 +242,10 @@ protected void processTxAttr(final EJBComponentDescription ejbComponentDescripti
return;
}

TransactionAttributeType txAttr = ejbComponentDescription.getTransactionAttributes().getAttribute(methodIntf, method);
MethodIntf defaultMethodIntf = (ejbComponentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
TransactionAttributeType txAttr = ejbComponentDescription.getTransactionAttributes().getAttribute(methodIntf, method, defaultMethodIntf);
txAttrs.put(new MethodTransactionAttributeKey(methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txAttr);
Integer txTimeout = ejbComponentDescription.getTransactionTimeouts().getAttribute(methodIntf, method);
Integer txTimeout = ejbComponentDescription.getTransactionTimeouts().getAttribute(methodIntf, method, defaultMethodIntf);
if (txTimeout != null) {
txTimeouts.put(new MethodTransactionAttributeKey(methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txTimeout);
}
Expand Down
Expand Up @@ -110,7 +110,12 @@ Map<ArrayKey, T> populate() {
}
};


public T getAttribute(MethodIntf methodIntf, Method method) {
return getAttribute(methodIntf, method, null);
}

public T getAttribute(MethodIntf methodIntf, Method method, MethodIntf defaultMethodIntf) {
assert methodIntf != null : "methodIntf is null";
assert method != null : "method is null";

Expand Down Expand Up @@ -138,7 +143,11 @@ public T getAttribute(MethodIntf methodIntf, Method method) {
attr = get(style1, className);
if (attr != null)
return attr;
return defaultAttribute;
if(defaultMethodIntf == null) {
return defaultAttribute;
} else {
return getAttribute(defaultMethodIntf, method);
}
}

public List<T> getAllAttributes(MethodIntf methodIntf, Method method) {
Expand Down
Expand Up @@ -43,4 +43,13 @@ public int transactionStatus() {
throw new RuntimeException(e);
}
}

@Override
public int transactionStatus2() {
try {
return transactionManager.getStatus();
} catch (SystemException e) {
throw new RuntimeException(e);
}
}
}
Expand Up @@ -94,4 +94,22 @@ public void testRemoteMethodHasMandatory() throws SystemException, NotSupportedE
}
}


@Test
public void testRemoteMethodHasMandatoryNoMethodIntf() throws SystemException, NotSupportedException, NamingException {
final UserTransaction userTransaction = (UserTransaction)new InitialContext().lookup("java:jboss/UserTransaction");
final TransactionRemote bean = (TransactionRemote) initialContext.lookup("java:module/" + DescriptorBean.class.getSimpleName() + "!" + TransactionRemote.class.getName());
userTransaction.begin();
try {
Assert.assertEquals(Status.STATUS_ACTIVE, bean.transactionStatus2());
} finally {
userTransaction.rollback();
}
try {
bean.transactionStatus2();
throw new RuntimeException("Expected an exception");
} catch (EJBTransactionRequiredException e) {
//ignore
}
}
}
Expand Up @@ -10,4 +10,7 @@ public interface TransactionLocal {

public int transactionStatus();


public int transactionStatus2();

}
Expand Up @@ -10,4 +10,5 @@ public interface TransactionRemote {

public int transactionStatus();

public int transactionStatus2();
}
Expand Up @@ -19,5 +19,12 @@
</method>
<trans-attribute>Mandatory</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DescriptorBean</ejb-name>
<method-name>transactionStatus2</method-name>
</method>
<trans-attribute>Mandatory</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

0 comments on commit 227751f

Please sign in to comment.