geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1055251 - in /geronimo/sandbox/djencks/txmanager: ./ geronimo-transaction/ geronimo-transaction/src/main/java/org/apache/geronimo/transaction/ geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/
Date Wed, 05 Jan 2011 00:28:20 GMT
Author: djencks
Date: Wed Jan  5 00:28:20 2011
New Revision: 1055251

URL: http://svn.apache.org/viewvc?rev=1055251&view=rev
Log:
set up our tm as an osgi DS

Added:
    geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
  (with props)
Modified:
    geronimo/sandbox/djencks/txmanager/geronimo-transaction/pom.xml
    geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
    geronimo/sandbox/djencks/txmanager/pom.xml

Modified: geronimo/sandbox/djencks/txmanager/geronimo-transaction/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-transaction/pom.xml?rev=1055251&r1=1055250&r2=1055251&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-transaction/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-transaction/pom.xml Wed Jan  5 00:28:20 2011
@@ -67,25 +67,64 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.apache.karaf</groupId>-->
+            <!--<artifactId>apache-karaf</artifactId>-->
+            <!--<version>2.1.99-SNAPSHOT</version>-->
+            <!--<type>pom</type>-->
+            <!--<scope>provided</scope>-->
+        <!--</dependency>-->
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
                 <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <!--<plugin>-->
+              <!--<groupId>org.apache.karaf.tooling</groupId>-->
+              <!--<artifactId>features-maven-plugin</artifactId>-->
+              <!--<version>2.1.99-SNAPSHOT</version>-->
+                <!--<executions>-->
+                  <!--<execution>-->
+                    <!--<id>generate</id>-->
+                    <!--<phase>generate-resources</phase>-->
+                    <!--<goals>-->
+                      <!--<goal>generate-features-xml</goal>-->
+                    <!--</goals>-->
+                    <!--<configuration>-->
+                      <!--&lt;!&ndash;<bundles>src/main/resources/bundles.properties</bundles>&ndash;&gt;-->
+                      <!--&lt;!&ndash;<kernelVersion>2.1.99-SNAPSHOT</kernelVersion>&ndash;&gt;-->
+                      <!--&lt;!&ndash;<outputFile>target/features.xml</outputFile>&ndash;&gt;-->
+                    <!--</configuration>-->
+                  <!--</execution>-->
+                <!--</executions>-->
+              <!--</plugin>-->
+            <plugin>
+                <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
                         <Export-Package>org.apache.geronimo.transaction*;version=3.0</Export-Package>
                         <Import-Package>
-                            org.objectweb.howl*;resolution:=optional,
-                            javax.resource.spi;version="1.5",
+                            javax.resource.spi;version="[1.5,2.0)",
                             *
                         </Import-Package>
+                        <Embed-Dependency>howl;inline=true</Embed-Dependency>
+                        
                     </instructions>
                 </configuration>
             </plugin>

Added: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java?rev=1055251&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
(added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
Wed Jan  5 00:28:20 2011
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.transaction;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import javax.resource.spi.XATerminator;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.geronimo.transaction.log.HOWLLog;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;
+import org.apache.geronimo.transaction.manager.MonitorableTransactionManager;
+import org.apache.geronimo.transaction.manager.NamedXAResourceFactory;
+import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
+import org.apache.geronimo.transaction.manager.TransactionImpl;
+import org.apache.geronimo.transaction.manager.TransactionManagerMonitor;
+import org.apache.geronimo.transaction.manager.XAWork;
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+import org.apache.geronimo.transaction.manager.XidImporter;
+import org.objectweb.howl.log.LogConfigurationException;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Component(metatype = true)
+@Service
+public class DSTransactionManager implements TransactionManager, UserTransaction, TransactionSynchronizationRegistry,
XidImporter, MonitorableTransactionManager, RecoverableTransactionManager, XATerminator, XAWork
{
+
+    @Property(byteValue = {71,84,77,73,68})
+    private static final String TM_ID = "tmId";
+
+    @Property(value = "org.objectweb.howl.log.BlockLogBuffer")
+    private static final String BUFFER_CLASS_NAME = "bufferClassName";
+
+    @Property(intValue = 4)
+    private static final String BUFFER_SIZE_KBYTES = "bufferSizeKBytes";
+
+    @Property(boolValue = true)
+    private static final String CHECKSUM_ENABLED = "checksumEnabled";
+
+    @Property(boolValue = true)
+    private static final String ADLER32_CHECKSUM = "adler32Checksum";
+
+    @Property(intValue = 50)
+    private static final String FLUSH_SLEEP_TIME_MILLISECONDS = "flushSleepTimeMilliseconds";
+
+    @Property(value = "txlog")
+    private static final String LOG_FILE_DIR = "logFileDir";
+
+    @Property(value = "log")
+    private static final String LOG_FILE_EXT = "logFileExt";
+
+    @Property(value = "howl")
+    private static final String LOG_FILE_NAME = "logFileName";
+
+    @Property(intValue = 512)
+    private static final String MAX_BLOCKS_PER_FILE = "maxBlocksPerFile";
+
+    @Property(intValue = 0)
+    private static final String MAX_BUFFERS = "maxBuffers";
+
+    @Property(intValue = 2)
+    private static final String MAX_LOG_FILES = "maxLogFiles";
+
+    @Property(intValue = 4)
+    private static final String MIN_BUFFERS = "minBuffers";
+
+    @Property(intValue = -1)
+    private static final String THREADS_WAITING_FORCE_THRESHOLD = "threadsWaitingForceThreshold";
+
+    @Property(intValue = 600)
+    private static final String DEFAULT_TRANSACTION_TIMEOUT_SECONDS = "defaultTransactionTimeoutSeconds";
+
+    private GeronimoTransactionManager delegate;
+
+    //osgi DS methods
+
+    @Activate
+    void activate(BundleContext bundleContext, Map properties) throws IOException, LogConfigurationException,
XAException {
+        //XID factory
+        byte[] tmId = (byte[]) properties.get(TM_ID);
+        XidFactory xidFactory = new XidFactoryImpl(tmId);
+
+        //HOWL log
+        String bufferClassName = (String) properties.get(BUFFER_CLASS_NAME);
+        int bufferSize = (Integer) properties.get(BUFFER_SIZE_KBYTES);
+        boolean checksumEnabled = (Boolean) properties.get(CHECKSUM_ENABLED);
+        boolean adler32Checksum = (Boolean) properties.get(ADLER32_CHECKSUM);
+        int flushSleepTimeMilliseconds = (Integer) properties.get(FLUSH_SLEEP_TIME_MILLISECONDS);
+        String logFileDir = (String) properties.get(LOG_FILE_DIR);
+        String logFileExt = (String) properties.get(LOG_FILE_EXT);
+        String logFileName = (String) properties.get(LOG_FILE_NAME);
+        int maxBlocksPerFile = (Integer) properties.get(MAX_BLOCKS_PER_FILE);
+        int maxBuffers = (Integer) properties.get(MAX_BUFFERS);
+        int maxLogFiles = (Integer) properties.get(MAX_LOG_FILES);
+        int minBuffers = (Integer) properties.get(MIN_BUFFERS);
+        int threadsWaitingForceThreshold = (Integer) properties.get(THREADS_WAITING_FORCE_THRESHOLD);
+        File serverBaseDir = bundleContext.getDataFile("");
+        HOWLLog howlLog = new HOWLLog(bufferClassName,
+                bufferSize,
+                checksumEnabled,
+                adler32Checksum,
+                flushSleepTimeMilliseconds,
+                logFileDir,
+                logFileExt,
+                logFileName,
+                maxBlocksPerFile,
+                maxBuffers,
+                maxLogFiles,
+                minBuffers,
+                threadsWaitingForceThreshold,
+                xidFactory,
+                serverBaseDir);
+
+        //tm
+        int defaultTransactionTimeoutSeconds = (Integer)properties.get(DEFAULT_TRANSACTION_TIMEOUT_SECONDS);
+        delegate = new GeronimoTransactionManager(defaultTransactionTimeoutSeconds, xidFactory,
howlLog);
+    }
+
+
+    public Transaction getTransaction() {
+        return delegate.getTransaction();
+    }
+
+    public void setTransactionTimeout(int seconds) throws SystemException {
+        delegate.setTransactionTimeout(seconds);
+    }
+
+    public int getStatus() throws SystemException {
+        return delegate.getStatus();
+    }
+
+    public void begin() throws NotSupportedException, SystemException {
+        delegate.begin();
+    }
+
+    public Transaction suspend() throws SystemException {
+        return delegate.suspend();
+    }
+
+    public void resume(Transaction tx) throws IllegalStateException, InvalidTransactionException,
SystemException {
+        delegate.resume(tx);
+    }
+
+    public Object getResource(Object key) {
+        return delegate.getResource(key);
+    }
+
+    public boolean getRollbackOnly() {
+        return delegate.getRollbackOnly();
+    }
+
+    public Object getTransactionKey() {
+        return delegate.getTransactionKey();
+    }
+
+    public int getTransactionStatus() {
+        return delegate.getTransactionStatus();
+    }
+
+    public void putResource(Object key, Object value) {
+        delegate.putResource(key, value);
+    }
+
+    public void registerInterposedSynchronization(Synchronization synchronization) {
+        delegate.registerInterposedSynchronization(synchronization);
+    }
+
+    public void setRollbackOnly() throws IllegalStateException {
+        delegate.setRollbackOnly();
+    }
+
+    public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException,
RollbackException, SecurityException, SystemException {
+        delegate.commit();
+    }
+
+    public void rollback() throws IllegalStateException, SecurityException, SystemException
{
+        delegate.rollback();
+    }
+
+    public Transaction importXid(Xid xid, long transactionTimeoutMilliseconds) throws XAException,
SystemException {
+        return delegate.importXid(xid, transactionTimeoutMilliseconds);
+    }
+
+    public void commit(Transaction tx, boolean onePhase) throws XAException {
+        delegate.commit(tx, onePhase);
+    }
+
+    public void forget(Transaction tx) throws XAException {
+        delegate.forget(tx);
+    }
+
+    public int prepare(Transaction tx) throws XAException {
+        return delegate.prepare(tx);
+    }
+
+    public void rollback(Transaction tx) throws XAException {
+        delegate.rollback(tx);
+    }
+
+    public void recoveryError(Exception e) {
+        delegate.recoveryError(e);
+    }
+
+    public void registerNamedXAResourceFactory(NamedXAResourceFactory namedXAResourceFactory)
{
+        delegate.registerNamedXAResourceFactory(namedXAResourceFactory);
+    }
+
+    public void unregisterNamedXAResourceFactory(String namedXAResourceFactoryName) {
+        delegate.unregisterNamedXAResourceFactory(namedXAResourceFactoryName);
+    }
+
+    public Map<Xid, TransactionImpl> getExternalXids() {
+        return delegate.getExternalXids();
+    }
+
+    public void addTransactionAssociationListener(TransactionManagerMonitor listener) {
+        delegate.addTransactionAssociationListener(listener);
+    }
+
+    public void removeTransactionAssociationListener(TransactionManagerMonitor listener)
{
+        delegate.removeTransactionAssociationListener(listener);
+    }
+
+    public void commit(Xid xid, boolean onePhase) throws XAException {
+        delegate.commit(xid, onePhase);
+    }
+
+    public void forget(Xid xid) throws XAException {
+        delegate.forget(xid);
+    }
+
+    public int prepare(Xid xid) throws XAException {
+        return delegate.prepare(xid);
+    }
+
+    public Xid[] recover(int flag) throws XAException {
+        return delegate.recover(flag);
+    }
+
+    public void rollback(Xid xid) throws XAException {
+        delegate.rollback(xid);
+    }
+
+    public void begin(Xid xid, long txTimeoutMillis) throws XAException, InvalidTransactionException,
SystemException, ImportedTransactionActiveException {
+        delegate.begin(xid, txTimeoutMillis);
+    }
+
+    public void end(Xid xid) throws XAException, SystemException {
+        delegate.end(xid);
+    }
+}

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java?rev=1055251&r1=1055250&r2=1055251&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
Wed Jan  5 00:28:20 2011
@@ -16,10 +16,10 @@
  */
 package org.apache.geronimo.transaction.manager;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+
 import javax.resource.spi.XATerminator;
 import javax.transaction.InvalidTransactionException;
 import javax.transaction.Status;

Modified: geronimo/sandbox/djencks/txmanager/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/pom.xml?rev=1055251&r1=1055250&r2=1055251&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/pom.xml Wed Jan  5 00:28:20 2011
@@ -26,7 +26,7 @@
         <groupId>org.apache.geronimo.genesis</groupId>
         <artifactId>genesis-java5-flava</artifactId>
         <version>2.0</version>
-        <relativePath />
+        <relativePath/>
     </parent>
 
     <groupId>org.apache.geronimo.components</groupId>
@@ -89,7 +89,7 @@
                 <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
                 <version>1.0</version>
             </dependency>
-                
+
             <dependency>
                 <groupId>org.apache.geronimo.specs</groupId>
                 <artifactId>geronimo-validation_1.0_spec</artifactId>
@@ -110,6 +110,16 @@
                 <scope>test</scope>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.apache.felix.scr.annotations</artifactId>
+                <version>1.4.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.core</artifactId>
+                <version>4.2.0</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -129,6 +139,22 @@
                     </configuration>
                 </plugin>
 
+                <plugin>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>maven-scr-plugin</artifactId>
+                    <version>1.6.0</version>
+                    <executions>
+                        <execution>
+                            <id>generate-scr-scrdescriptor</id>
+                            <goals>
+                                <goal>scr</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                    <configuration>
+                        <specVersion>1.1</specVersion>
+                    </configuration>
+                </plugin>
             </plugins>
         </pluginManagement>
     </build>



Mime
View raw message