You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/04/07 21:22:16 UTC
cvs commit: incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment WARConfigBuilder.java
dain 2004/04/07 12:22:16
Modified: modules/jetty/src/java/org/apache/geronimo/jetty
JettyWebApplicationContext.java
modules/jetty/src/java/org/apache/geronimo/jetty/deployment
WARConfigBuilder.java
Log:
Changed WarConfigBuilder to provied the JettyWebApplicationContext with a
UserTransaction.
Change JettyWebApplicationContext to set the UserTransaction online before
calling the web app and offline after calling the web app.
Revision Changes Path
1.13 +5 -1 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java
Index: JettyWebApplicationContext.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JettyWebApplicationContext.java 6 Apr 2004 00:21:21 -0000 1.12
+++ JettyWebApplicationContext.java 7 Apr 2004 19:22:15 -0000 1.13
@@ -149,6 +149,9 @@
// set up Security Context
PolicyContext.setContextID(policyContextID);
+ // Turn on the UserTransaction
+ userTransaction.setOnline(true);
+
if (TransactionContext.getContext() == null) {
TransactionContext.setContext(new UnspecifiedTransactionContext());
}
@@ -167,6 +170,7 @@
} catch (ResourceException e) {
throw new RuntimeException(e);
} finally {
+ userTransaction.setOnline(false);
PolicyContext.setContextID(oldPolicyContextID);
RootContext.setComponentContext(oldComponentContext);
}
1.17 +18 -6 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigBuilder.java
Index: WARConfigBuilder.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigBuilder.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WARConfigBuilder.java 3 Apr 2004 22:37:58 -0000 1.16
+++ WARConfigBuilder.java 7 Apr 2004 19:22:15 -0000 1.17
@@ -40,6 +40,8 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.transaction.UserTransaction;
+import javax.naming.NamingException;
import org.apache.geronimo.deployment.ConfigurationBuilder;
import org.apache.geronimo.deployment.DeploymentContext;
@@ -65,6 +67,7 @@
import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
import org.apache.geronimo.xbeans.j2ee.WebAppType;
import org.apache.geronimo.common.xml.XmlBeansUtil;
+import org.apache.geronimo.transaction.UserTransactionImpl;
import org.apache.xmlbeans.SchemaTypeLoader;
import org.apache.xmlbeans.XmlBeans;
@@ -274,7 +277,8 @@
throw new DeploymentException("Unable to construct ObjectName", e);
}
- ReadOnlyContext compContext = buildComponentContext(webApp, jettyWebApp, cl);
+ UserTransaction userTransaction = new UserTransactionImpl();
+ ReadOnlyContext compContext = buildComponentContext(webApp, jettyWebApp, userTransaction, cl);
GBeanMBean gbean = new GBeanMBean(JettyWebApplicationContext.GBEAN_INFO);
try {
@@ -283,18 +287,27 @@
gbean.setAttribute("ContextPriorityClassLoader", Boolean.valueOf(jettyWebApp.getContextPriorityClassloader()));
gbean.setAttribute("PolicyContextID", null);
gbean.setAttribute("ComponentContext", compContext);
+ gbean.setAttribute("UserTransaction", userTransaction);
gbean.setReferencePatterns("Configuration", Collections.singleton(ConfigurationManager.getConfigObjectName(configID)));
gbean.setReferencePatterns("JettyContainer", Collections.singleton(new ObjectName("*:type=WebContainer,container=Jetty"))); // @todo configurable
- gbean.setReferencePatterns("TransactionManager", Collections.EMPTY_SET);
- gbean.setReferencePatterns("TrackedConnectionAssociator", Collections.EMPTY_SET);
+ gbean.setReferencePatterns("TransactionManager", Collections.singleton(new ObjectName("*:type=TransactionManager,*")));
+ gbean.setReferencePatterns("TrackedConnectionAssociator", Collections.singleton(new ObjectName("*:type=ConnectionTracker,*")));
} catch (Exception e) {
throw new DeploymentException("Unable to initialize webapp GBean", e);
}
context.addGBean(name, gbean);
}
- private ReadOnlyContext buildComponentContext(WebAppType webApp, JettyWebAppType jettyWebApp, ClassLoader cl) throws DeploymentException {
+ private ReadOnlyContext buildComponentContext(WebAppType webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader cl) throws DeploymentException {
ComponentContextBuilder builder = new ComponentContextBuilder(new JMXReferenceFactory());
+ if (userTransaction != null) {
+ try {
+ builder.addUserTransaction(userTransaction);
+ } catch (NamingException e) {
+ throw new DeploymentException("Unable to bind UserTransaction into ENC", e);
+ }
+ }
+
EnvEntryType[] envEntries = webApp.getEnvEntryArray();
ENCConfigBuilder.addEnvEntries(envEntries, builder);
// todo ejb-ref
@@ -316,7 +329,6 @@
}
ENCConfigBuilder.addResourceEnvRefs(webApp.getResourceEnvRefArray(), cl, resourceEnvRefMap, builder);
// todo message-destination-ref
- // todo usertransaction
return builder.getContext();
}