Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1790 - in development/laboratory/planet/facilities/transactions: . facility facility/src facility/src/main facility/src/main/net facility/src/main/net/dpml facility/src/main/net/dpml/tx

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1790 - in development/laboratory/planet/facilities/transactions: . facility facility/src facility/src/main facility/src/main/net facility/src/main/net/dpml facility/src/main/net/dpml/tx
  • Date: Wed, 16 Feb 2005 18:41:57 +0100

Author: niclas
Date: Wed Feb 16 18:41:56 2005
New Revision: 1790

Added:
development/laboratory/planet/facilities/transactions/
development/laboratory/planet/facilities/transactions/build.xml
(contents, props changed)
development/laboratory/planet/facilities/transactions/facility/
development/laboratory/planet/facilities/transactions/facility/.classpath
development/laboratory/planet/facilities/transactions/facility/.project
development/laboratory/planet/facilities/transactions/facility/build.xml
(contents, props changed)
development/laboratory/planet/facilities/transactions/facility/src/
development/laboratory/planet/facilities/transactions/facility/src/main/

development/laboratory/planet/facilities/transactions/facility/src/main/net/

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionContext.java
(contents, props changed)

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionFacility.java
(contents, props changed)

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionContext.java
(contents, props changed)

development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionFacility.java
(contents, props changed)
development/laboratory/planet/facilities/transactions/index.xml
(contents, props changed)
Log:
Using JOTM as a transaction manager.

Added: development/laboratory/planet/facilities/transactions/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/facilities/transactions/build.xml Wed
Feb 16 18:41:56 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2004 Niclas Hedhman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="dpml-tx" default="default" basedir="."
+ xmlns:transit="antlib:net.dpml.transit">
+
+ <transit:import uri="artifact:template:dpml/magic/reactor"/>
+
+</project>

Added:
development/laboratory/planet/facilities/transactions/facility/.classpath
==============================================================================
--- (empty file)
+++ development/laboratory/planet/facilities/transactions/facility/.classpath
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/public/jars/dpml-logging-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/public/jars/dpml-parameters-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/public/jars/dpml-service-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/sun/java/jta/jars/jta-spec-1.0.1B.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/transit/jars/dpml-transit-main-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/jotm/jars/jotm-1.5.3.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/public/jars/dpml-context-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/protected/jars/dpml-composition-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/protected/jars/dpml-meta-api-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="MAGIC_CACHE/dpml/metro/public/jars/dpml-activity-api-SNAPSHOT.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: development/laboratory/planet/facilities/transactions/facility/.project
==============================================================================
--- (empty file)
+++ development/laboratory/planet/facilities/transactions/facility/.project
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tx-facility</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>

Added:
development/laboratory/planet/facilities/transactions/facility/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/facilities/transactions/facility/build.xml
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-tx-facility" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>

Added:
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionContext.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionContext.java
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004 niclas
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package net.dpml.tx;
+
+import javax.transaction.UserTransaction;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+import net.dpml.parameters.Parameters;
+
+/** TODO
+ */
+public class DefaultTransactionContext
+ implements TransactionContext
+{
+ private Context m_context;
+ private TransactionFacility m_facility;
+
+ /**
+ * The DefaultTransactionContext supports to find the kernel
TransactionFacility, which
+ * is then used to get the UserTransactions from.
+ *
+ * @param ctx Context to be provided to this component.
+ * @param params the parameters to configure this component with.
+ * @exception ContextException if no TransactionFacility has been
installed at the
+ *
+ * @metro.entry key="urn:metro:name"
+ * @metro.entry key="urn:metro:partition"
+ * @metro.entry key="urn:metro:dir" type="java.io.File"
+ * @metro.entry key="urn:metro:temp" type="java.io.File"
+ * @metro.entry key="urn:composition:containment.model"
+ * type="net.dpml.composition.model.ContainmentModel"
+ */
+ public DefaultTransactionContext( Context ctx, Parameters params )
+ throws ContextException
+ {
+ m_context = ctx;
+ String txFacilityPath = params.getParameter( "tx-facility-path",
"/transactions/facility" ); //$NON-NLS-1$ //$NON-NLS-2$
+ ContainmentModel model = (ContainmentModel) ctx.get(
"urn:composition:containment.model" ); //$NON-NLS-1$
+ Object obj = model.getModel( txFacilityPath );
+ if( obj instanceof TransactionFacility == false )
+ throw new ContextException( "TransactionFacility not installed
in kernel." ); //$NON-NLS-1$
+ m_facility = (TransactionFacility) obj;
+ }
+
+ /**
+ * @return the UserTransaction that is associated with this thread.
+ *
+ */
+ public UserTransaction getTransaction()
+ {
+ return m_facility.getUserTransaction();
+ }
+
+ /** Returns the Object associated with the key in the standard context.
+ * @param key the key to the context entry of interest. The standard
keys are support, as well as
+ * "urn:transactions:facility.path"
+ * @return the request Object associated with standard key.
+ * @exception ContextException if the key doesn't correspond to a
context entry.
+ */
+ public Object get( Object key )
+ throws ContextException
+ {
+ if( "urn:transactions:facility.path".equals( key ) )
//$NON-NLS-1$
+ return getTransaction();
+ return m_context.get( key );
+ }
+
+}

Added:
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionFacility.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/DefaultTransactionFacility.java
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004 niclas
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package net.dpml.tx;
+
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+import net.dpml.activity.Disposable;
+import net.dpml.composition.event.CompositionEvent;
+import net.dpml.composition.event.CompositionListener;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+import net.dpml.logging.Logger;
+import net.dpml.parameters.Parameters;
+import org.objectweb.jotm.Jotm;
+import org.objectweb.transaction.jta.TMService;
+
+/** The DefaultTransactionFacility uses JOTM as the underlying implementation
+ * of the Java Transaction API.
+ *
+ * @metro.component name="transaction-facility" lifestyle="singleton"
+ * @metro.service type="net.dpml.tx.TransactionFacility"
+ */
+public class DefaultTransactionFacility
+ implements CompositionListener, TransactionFacility, Disposable
+{
+ /** The Logger used in the component. It is named "transactions". */
+ private Logger m_logger;
+
+ /** The JOTM instance that is the underlying implementation of JTA
driving
+ * this facility.
+ */
+ private TMService m_TmService;
+
+ /** The ContainmentModel of the container. */
+ private ContainmentModel m_model;
+
+ /**
+ * @param ctx the context containing the ContainmentModel.
+ * @param logger the logger to use for this component.
+ * @param params the parameters to configure this component with.
+ *
+ * @throws ContextException can only happen for broken containers.
+ * @throws NamingException if the parameter "bound" is true, and the
+ * underlying TransactionManager can not connect to the JNDI.
+ *
+ * @metro.logger name="transactions"
+ * @metro.entry key="urn:composition:containment.model"
+ * type="net.dpml.composition.model.ContainmentModel"
+ */
+ public DefaultTransactionFacility( Context ctx, Logger logger,
Parameters params )
+ throws ContextException, NamingException
+ {
+ m_model = (ContainmentModel)
ctx.get("urn:composition:containment.model" ); //$NON-NLS-1$
+ boolean local = params.getParameterAsBoolean( "local", true );
//$NON-NLS-1$
+ boolean bound = params.getParameterAsBoolean( "bound", false );
//$NON-NLS-1$
+ m_TmService = new Jotm( local, bound );
+ m_logger = logger;
+ m_model.addCompositionListener( this );
+ }
+
+ /** Called by the container to instruct the component to clean up after
itself.
+ * This method should not be called by anything else.
+ */
+ public void dispose()
+ {
+ m_model.removeCompositionListener( this );
+ }
+
+ /** Called by the composition model when there is an addition in the
composition.
+ * Not called by anything except the container.
+ * @param event the event sent by the composition model.
+ */
+ public void modelAdded( CompositionEvent event )
+ {
+ if( m_logger.isDebugEnabled() )
+ m_logger.debug( "modelAdded: " + event ); //$NON-NLS-1$
+ // TODO if the add model is a XAResource, then we need to deal with
it.
+ // somehow need to associate it with the transaction manager.
+ }
+
+ /** Called by the composition model when there is removal in the
composition.
+ * Not called by anything except the container.
+ * @param event the event sent by the composition model.
+ */
+ public void modelRemoved( CompositionEvent event )
+ {
+ if( m_logger.isDebugEnabled() )
+ m_logger.debug( "modelRemoved: " + event ); //$NON-NLS-1$
+ }
+
+ /** Retrieves the UserTransaction associated with the current thread.
+ * @return the UserTransaction that is either in progress, or a new one
+ * if none exist for the current thread.
+ */
+ public UserTransaction getUserTransaction()
+ {
+ return m_TmService.getUserTransaction();
+ }
+}

Added:
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionContext.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionContext.java
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004 niclas
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package net.dpml.tx;
+
+import javax.transaction.UserTransaction;
+import net.dpml.context.Context;
+
+/** TODO
+ */
+public interface TransactionContext extends Context
+{
+ /**
+ * @return the UserTransaction that is associated with this thread.
+ *
+ */
+ UserTransaction getTransaction();
+}

Added:
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionFacility.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/facilities/transactions/facility/src/main/net/dpml/tx/TransactionFacility.java
Wed Feb 16 18:41:56 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004 niclas
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tx;
+
+import javax.transaction.UserTransaction;
+
+
+/** TODO
+ */
+public interface TransactionFacility
+{
+ /** Retrieves the UserTransaction associated with the current thread.
+ * @return the UserTransaction that is either in progress, or a new one
+ * if none exist for the current thread.
+ */
+ UserTransaction getUserTransaction();
+}
\ No newline at end of file

Added: development/laboratory/planet/facilities/transactions/index.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/facilities/transactions/index.xml Wed
Feb 16 18:41:56 2005
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright 2004 Stephen J McConnell
+ Copyright 2004 Niclas Hedhman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<index key="dpml-tx">
+ <import uri="artifact:module:dpml/metro/dpml-metro#SNAPSHOT"/>
+ <import uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT"/>
+ <import uri="artifact:module:dpml/transit/dpml-transit#SNAPSHOT"/>
+
+ <resource>
+ <info>
+ <group>sun/java/jta</group>
+ <name>jta-spec</name>
+ <version>1.0.1B</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>jotm</group>
+ <name>jotm</name>
+ <version>1.5.3</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>jotm</group>
+ <name>jotm-carol</name>
+ <version>1.5.3</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>jotm</group>
+ <name>jotm-jrmp-stubs</name>
+ <version>1.5.3</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>commons-logging</group>
+ <name>commons-logging</name>
+ <version>1.0.4</version>
+ </info>
+ </resource>
+
+ <project basedir="facility">
+ <info>
+ <group>dpml/facilities/tx</group>
+ <name>dpml-tx-facility</name>
+ <version>1.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jta-spec" />
+ <include key="dpml-transit-main" />
+ <include key="jotm" />
+ <include key="jotm-carol" />
+ <include key="jotm-jrmp-stubs" />
+ <include key="commons-logging" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+</index>



  • svn commit: r1790 - in development/laboratory/planet/facilities/transactions: . facility facility/src facility/src/main facility/src/main/net facility/src/main/net/dpml facility/src/main/net/dpml/tx, niclas, 02/16/2005

Archive powered by MHonArc 2.6.24.

Top of Page