djencks 2005/06/01 22:57:01
Modified: modules/openejb-builder/src/java/org/openejb/deployment
AbstractContainerBuilder.java CMPEntityBuilder.java
ContainerBuilder.java EntityBuilder.java
SessionBuilder.java
Log:
GERONIMO-659 Make the ejb container point to the TSS gbean, not the TSS to
the ejb container. Also GERONIMO-658, use nice short config to find the TSS
bean
Revision Changes Path
1.14 +15 -5
openejb/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java
Index: AbstractContainerBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AbstractContainerBuilder.java 19 Apr 2005 23:37:03 -0000 1.13
+++ AbstractContainerBuilder.java 2 Jun 2005 02:57:00 -0000 1.14
@@ -62,6 +62,7 @@
import org.apache.geronimo.transaction.TrackedConnectionAssociator;
import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.apache.geronimo.transaction.context.UserTransactionImpl;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.openejb.EJBContainer;
import org.openejb.EJBInterfaceType;
import org.openejb.GenericEJBContainer;
@@ -350,8 +351,15 @@
return (EJBContainer) buildIt(true);
}
- public GBeanData createConfiguration() throws Exception {
- return (GBeanData) buildIt(false);
+ public GBeanData createConfiguration(ObjectName containerObjectName,
ObjectName transactionContextManagerObjectName, ObjectName
connectionTrackerObjectName, ObjectName tssBeanObjectName) throws Exception {
+ GBeanData gbean = (GBeanData) buildIt(false);
+ gbean.setName(containerObjectName);
+ gbean.setReferencePattern("TransactionContextManager",
transactionContextManagerObjectName);
+ gbean.setReferencePattern("TrackedConnectionAssociator",
connectionTrackerObjectName);
+ if (tssBeanObjectName != null) {
+ gbean.setReferencePattern("TSSBean", tssBeanObjectName);
+ }
+ return gbean;
}
protected abstract Object buildIt(boolean buildContainer) throws
Exception;
@@ -473,6 +481,7 @@
null, //kernel
getDefaultPrincipal(),
runAs,
+ null,
getHomeTxPolicyConfig(),
getRemoteTxPolicyConfig(),
Thread.currentThread().getContextClassLoader());
@@ -500,8 +509,8 @@
gbean.setReferencePattern("Timer", timerName);
gbean.setAttribute("DefaultPrincipal", getDefaultPrincipal());
gbean.setAttribute("RunAsSubject", getRunAs());
- gbean.setAttribute("HomeTxPolicyConfig", getHomeTxPolicyConfig());
- gbean.setAttribute("RemoteTxPolicyConfig",
getRemoteTxPolicyConfig());
+ gbean.setAttribute("homeTxPolicyConfig", getHomeTxPolicyConfig());
+ gbean.setAttribute("remoteTxPolicyConfig",
getRemoteTxPolicyConfig());
return gbean;
}
@@ -520,4 +529,5 @@
}
return timerName;
}
+
}
1.30 +4 -9
openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPEntityBuilder.java
Index: CMPEntityBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPEntityBuilder.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- CMPEntityBuilder.java 17 May 2005 15:49:37 -0000 1.29
+++ CMPEntityBuilder.java 2 Jun 2005 02:57:01 -0000 1.30
@@ -58,14 +58,13 @@
import java.util.Set;
import javax.management.ObjectName;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.j2ee.deployment.EARContext;
import org.apache.geronimo.j2ee.deployment.EJBModule;
import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
import org.apache.geronimo.kernel.ClassLoading;
+import org.apache.geronimo.security.jacc.ComponentPermissions;
import org.apache.geronimo.xbeans.j2ee.CmpFieldType;
import org.apache.geronimo.xbeans.j2ee.EjbJarType;
import org.apache.geronimo.xbeans.j2ee.EjbNameType;
@@ -75,7 +74,6 @@
import org.apache.geronimo.xbeans.j2ee.EntityBeanType;
import org.apache.geronimo.xbeans.j2ee.JavaTypeType;
import org.apache.geronimo.xbeans.j2ee.QueryType;
-import org.apache.geronimo.security.jacc.ComponentPermissions;
import org.openejb.entity.cmp.PrimaryKeyGeneratorWrapper;
import org.openejb.proxy.EJBProxyFactory;
import org.openejb.transaction.TransactionPolicySource;
@@ -560,7 +558,7 @@
String pkColumn = att.getPhysicalName();
String fkColumn = (String) pkToFkMap.get(pkColumn);
if (null == fkColumn) {
- throw new DeploymentException("Role " + sourceRoleInfo + "
is misconfigured: primary key column [" +
+ throw new DeploymentException("Role " + sourceRoleInfo + "
is misconfigured: primary key column [" +
pkColumn + "] is not mapped to a foreign key.");
}
pkToFkMapEJB.put(pkEJB.getAttribute(att.getName()), new
FKField(fkColumn, att.getType()));
@@ -725,10 +723,7 @@
builder.setTransactionManagerDelegate(tmDelegate);
try {
- GBeanData gbean = builder.createConfiguration();
- gbean.setName(containerObjectName);
- gbean.setReferencePattern("TransactionContextManager",
earContext.getTransactionContextManagerObjectName());
- gbean.setReferencePattern("TrackedConnectionAssociator",
earContext.getConnectionTrackerObjectName());
+ GBeanData gbean =
builder.createConfiguration(containerObjectName,
earContext.getTransactionContextManagerObjectName(),
earContext.getConnectionTrackerObjectName(),
getTssBeanObjectName(openejbEntityBean, earContext));
return gbean;
} catch (Throwable e) {
throw new DeploymentException("Unable to initialize EJBContainer
GBean: ejbName [" + ejbName + "]", e);
1.7 +3 -3
openejb/modules/openejb-builder/src/java/org/openejb/deployment/ContainerBuilder.java
Index: ContainerBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/ContainerBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContainerBuilder.java 15 Mar 2005 05:32:41 -0000 1.6
+++ ContainerBuilder.java 2 Jun 2005 02:57:01 -0000 1.7
@@ -126,7 +126,7 @@
EJBContainer createContainer() throws Exception;
- GBeanData createConfiguration() throws Exception;
+ GBeanData createConfiguration(ObjectName containerObjectName, ObjectName
transactionContextManagerObjectName, ObjectName
trackedConnectionAssociatorObjectName, ObjectName tssBeanObjectName) throws
Exception;
ObjectName getTransactedTimerName();
1.18 +42 -4
openejb/modules/openejb-builder/src/java/org/openejb/deployment/EntityBuilder.java
Index: EntityBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/EntityBuilder.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- EntityBuilder.java 18 Apr 2005 19:05:15 -0000 1.17
+++ EntityBuilder.java 2 Jun 2005 02:57:01 -0000 1.18
@@ -82,6 +82,7 @@
import org.apache.geronimo.xbeans.j2ee.ServiceRefType;
import org.openejb.transaction.TransactionPolicySource;
import org.openejb.xbeans.ejbjar.OpenejbEntityBeanType;
+import org.openejb.xbeans.ejbjar.OpenejbTssType;
class EntityBuilder extends BeanBuilder {
@@ -131,15 +132,52 @@
processEnvironmentRefs(builder, earContext, ejbModule, entityBean,
openejbEntityBean, null, cl);
+ ObjectName tssBeanObjectName =
getTssBeanObjectName(openejbEntityBean, earContext);
+
try {
- GBeanData gbean = builder.createConfiguration();
- gbean.setName(containerObjectName);
- gbean.setReferencePattern("TransactionContextManager",
earContext.getTransactionContextManagerObjectName());
- gbean.setReferencePattern("TrackedConnectionAssociator",
earContext.getConnectionTrackerObjectName());
+ GBeanData gbean =
builder.createConfiguration(containerObjectName,
earContext.getTransactionContextManagerObjectName(),
earContext.getConnectionTrackerObjectName(), tssBeanObjectName);
return gbean;
} catch (Throwable e) {
throw new DeploymentException("Unable to initialize EJBContainer
GBean: ejbName=" + ejbName, e);
}
+ }
+
+ protected ObjectName getTssBeanObjectName(OpenejbEntityBeanType
openejbEntityBean, EARContext earContext) throws DeploymentException {
+ ObjectName tssBeanObjectName = null;
+ if (openejbEntityBean != null) {
+ if (openejbEntityBean.isSetTssName()) {
+ String tssName = openejbEntityBean.getTssName().trim();
+ try {
+ tssBeanObjectName = ObjectName.getInstance(tssName);
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Invalid object name for
tss bean", e);
+ }
+ } else if (openejbEntityBean.isSetTssLink()) {
+ String tssBeanLink = openejbEntityBean.getTssLink().trim();
+ tssBeanObjectName =
earContext.getRefContext().locateComponent(tssBeanLink, NameFactory.CORBA_TSS,
earContext.getJ2eeContext(), earContext, "TSS GBean");
+ } else if (openejbEntityBean.isSetTss()) {
+ OpenejbTssType tss = openejbEntityBean.getTss();
+ try {
+ tssBeanObjectName =
NameFactory.getComponentName(getStringValue(tss.getDomain()),
+ getStringValue(tss.getServer()),
+ getStringValue(tss.getApplication()),
+ getStringValue(tss.getModule()),
+ getStringValue(tss.getName()),
+ getStringValue(NameFactory.CORBA_TSS),
+ earContext.getJ2eeContext());
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Invalid object name for
tss bean", e);
+ }
+ }
+ }
+ return tssBeanObjectName;
+ }
+
+ private String getStringValue(String in) {
+ if (in == null) {
+ return null;
+ }
+ return in.trim();
}
public ObjectName createEJBObjectName(J2eeContext moduleJ2eeContext,
EntityBeanType entityBean) throws DeploymentException {
1.25 +39 -6
openejb/modules/openejb-builder/src/java/org/openejb/deployment/SessionBuilder.java
Index: SessionBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/SessionBuilder.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SessionBuilder.java 17 May 2005 00:29:27 -0000 1.24
+++ SessionBuilder.java 2 Jun 2005 02:57:01 -0000 1.25
@@ -97,6 +97,7 @@
import org.openejb.transaction.TransactionPolicySource;
import org.openejb.transaction.TransactionPolicyType;
import org.openejb.xbeans.ejbjar.OpenejbSessionBeanType;
+import org.openejb.xbeans.ejbjar.OpenejbTssType;
class SessionBuilder extends BeanBuilder {
@@ -248,17 +249,49 @@
processEnvironmentRefs(builder, earContext, ejbModule, sessionBean,
openejbSessionBean, userTransaction, cl);
+ ObjectName tssBeanObjectName = null;
+ if (openejbSessionBean != null) {
+ if (openejbSessionBean.isSetTssName()) {
+ String tssName = openejbSessionBean.getTssName().trim();
+ try {
+ tssBeanObjectName = ObjectName.getInstance(tssName);
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Invalid object name for
tss bean", e);
+ }
+ } else if (openejbSessionBean.isSetTssLink()) {
+ String tssBeanLink = openejbSessionBean.getTssLink().trim();
+ tssBeanObjectName =
earContext.getRefContext().locateComponent(tssBeanLink, NameFactory.CORBA_TSS,
earContext.getJ2eeContext(), earContext, "TSS GBean");
+ } else if (openejbSessionBean.isSetTss()) {
+ OpenejbTssType tss = openejbSessionBean.getTss();
+ try {
+ tssBeanObjectName =
NameFactory.getComponentName(getStringValue(tss.getDomain()),
+ getStringValue(tss.getServer()),
+ getStringValue(tss.getApplication()),
+ getStringValue(tss.getModule()),
+ getStringValue(tss.getName()),
+ NameFactory.CORBA_TSS,
+ earContext.getJ2eeContext());
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Invalid object name for
tss bean", e);
+ }
+
+ }
+ }
+
+ GBeanData sessionGBean;
try {
- GBeanData gbean = builder.createConfiguration();
- gbean.setName(sessionObjectName);
- gbean.setReferencePattern("TransactionContextManager",
earContext.getTransactionContextManagerObjectName());
- gbean.setReferencePattern("TrackedConnectionAssociator",
earContext.getConnectionTrackerObjectName());
- result = gbean;
+ sessionGBean = builder.createConfiguration(sessionObjectName,
earContext.getTransactionContextManagerObjectName(),
earContext.getConnectionTrackerObjectName(), tssBeanObjectName);
} catch (Throwable e) {
throw new DeploymentException("Unable to initialize EJBContainer
GBean: ejbName" + ejbName, e);
}
- GBeanData sessionGBean = result;
earContext.addGBean(sessionGBean);
+ }
+
+ private String getStringValue(String in) {
+ if (in == null) {
+ return null;
+ }
+ return in.trim();
}
private HandlerChainConfiguration
createHandlerChainConfiguration(JarFile moduleFile, String ejbName, ClassLoader
cl) throws DeploymentException {