On Apr 20, 2007, at 1:05 AM, [EMAIL PROTECTED] wrote:
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/
src/main/java/org/apache/openejb/config/AutoConfig.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/
container/openejb-core/src/main/java/org/apache/openejb/config/
AutoConfig.java?view=diff&rev=530644&r1=530643&r2=530644
======================================================================
========
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/
main/java/org/apache/openejb/config/AutoConfig.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/
main/java/org/apache/openejb/config/AutoConfig.java Thu Apr 19
22:05:36 2007
<snip>
+ /**
+ * Set destination, destinationType, clientId and
subscriptionName in the MDB activation config.
+ */
+ private void processActivationConfig(EjbModule ejbModule)
throws OpenEJBException {
OpenejbJar openejbJar;
if (ejbModule.getOpenejbJar() != null) {
openejbJar = ejbModule.getOpenejbJar();
@@ -108,238 +136,658 @@
ejbModule.setOpenejbJar(openejbJar);
}
- Bean[] beans = EjbJarUtils.getBeans(ejbModule.getEjbJar());
+ for (EnterpriseBean bean : ejbModule.getEjbJar
().getEnterpriseBeans()) {
+ if (bean instanceof MessageDrivenBean) {
+ MessageDrivenBean mdb = (MessageDrivenBean) bean;
+
+ EjbDeployment ejbDeployment =
openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
+ if (ejbDeployment == null) {
+ throw new OpenEJBException("No ejb deployment
found for ejb " + bean.getEjbName());
+ }
- for (Bean bean : beans) {
+ if (mdb.getActivationConfig() == null) {
+ mdb.setActivationConfig(new ActivationConfig());
+ }
- EjbDeployment ejbDeployment =
openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
- if (ejbDeployment == null) {
- throw new OpenEJBException("No ejb deployment
found for ejb " + bean.getEjbName());
- }
+ Properties properties = mdb.getActivationConfig
().toProperties();
- if (ejbDeployment.getContainerId() == null && !skipMdb
(bean.getBean())) {
- Class<? extends ContainerInfo> containerInfoType =
ConfigurationFactory.getContainerInfoType(bean.getType());
- String containerId = getUsableContainer
(containerInfoType, bean.getBean());
+ // destination
+ String destination = properties.getProperty
("destination");
+ if (destination == null) {
+ destination = ejbDeployment.getDeploymentId();
+ mdb.getActivationConfig().addProperty
("destination", destination);
+ }
- if (containerId == null){
- if (autoCreateContainers) {
- ContainerInfo containerInfo =
configFactory.configureService(containerInfoType);
- logger.warning("Auto-creating a container
for bean " + ejbDeployment.getDeploymentId() + ": Container(type="
+ bean.getType() + ", id=" + containerInfo.id + ")");
- containerId = installContainer
(containerInfo);
- } else {
- throw new OpenEJBException("A container of
type " + bean.getType() + " must be declared in the configuration
file for bean: "+bean.getEjbName());
+ // destination identifier
+ ResourceLink link = ejbDeployment.getResourceLink
("openejb/destination");
+ if (link == null && mdb.getMessageDestinationLink
() == null) {
+ link = new ResourceLink();
+ link.setResId(destination);
+ link.setResRefName("openejb/destination");
+ ejbDeployment.addResourceLink(link);
+ }
+
+ // destination type
+ String destinationType = properties.getProperty
("destinationType");
+ if (destinationType == null &&
mdb.getMessageDestinationType() != null) {
+ destinationType = mdb.getMessageDestinationType
();
+ mdb.getActivationConfig().addProperty
("destinationType", destinationType);
+ }
+ if (mdb.getMessageDestinationType() == null) {
+ mdb.setMessageDestinationType(destinationType);
+ }
+
+ // topics need a clientId and subscriptionName
+ if ("javax.jms.Topic".equals(destinationType)) {
+ if (!properties.containsKey("clientId")) {
+ mdb.getActivationConfig().addProperty
("clientId", ejbDeployment.getDeploymentId());
+ }
+ if (!properties.containsKey
("subscriptionName")) {
+ mdb.getActivationConfig().addProperty
("subscriptionName", ejbDeployment.getDeploymentId() +
"_subscription");
}
}
- ejbDeployment.setContainerId(containerId);
}
+ }
+ }
Dain,
My reading of the JCA 1.5 spec says that "destination" is a required
ActivationSpec property only for JMS Endpoints. The above change
makes it required in all cases. This causes problems for non-JMS
ActivationSpec implementations -- as we are unable to configure
"destination" properties on the ActivationSpec during deployment.
--kevan