[kune-commits] r1747 - in trunk: . src/main/java/cc/kune/core/server/init src/main/java/cc/kune/core/server/persist src/main/java/com/google src/main/java/com/google/inject src/main/java/com/google/inject/persist src/main/java/com/google/inject/persist/jpa src/test/java/com/google/inject/persist/jpa

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Wed Mar 7 14:08:17 CET 2012


Author: vjrj_
Date: 2012-03-07 14:08:17 +0100 (Wed, 07 Mar 2012)
New Revision: 1747

Added:
   trunk/src/main/java/com/google/inject/
   trunk/src/main/java/com/google/inject/persist/
   trunk/src/main/java/com/google/inject/persist/jpa/
   trunk/src/main/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java
Removed:
   trunk/CHANGING_DOMAIN_DOES_NOT_WORK
   trunk/src/main/java/cc/kune/core/server/init/KuneJpaPersistModule.java
   trunk/src/test/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java
Modified:
   trunk/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java
Log:
NEW - # 201: Add Openfire to the persist system so we can connect and get xmpp users info 
http://kune.ourproject.org/issues/ticket/201

Deleted: trunk/CHANGING_DOMAIN_DOES_NOT_WORK
===================================================================
--- trunk/CHANGING_DOMAIN_DOES_NOT_WORK	2012-03-07 12:19:26 UTC (rev 1746)
+++ trunk/CHANGING_DOMAIN_DOES_NOT_WORK	2012-03-07 13:08:17 UTC (rev 1747)
@@ -1,42 +0,0 @@
-=CHANGING THE DOMAIN OF A KUNE SERVER=
-
-Suppose that we want to change from domain.old to domain.new in a kune server deployment.
-
-==Prerrequisites==
-
-* Make a backup of /var/lib/kune/, your db and any other location for wave info (_accounts, _deltas, etc)
-* Be sure that domain.new can be resolved correctly ($ dig domain.new), also the SRV records (see INSTALL)
-* stop kune
-
-==Do the job== 
-
-===Update configurations and stores===
-* in _accounts, _deltas 
-
-for i in `grep -ril domain.old /var/lib/kune/_accounts`; do perl -p -i -e 's/domain.old/domain.new/g' $i ; done
-for i in `grep -ril domain.old /var/lib/kune/_deltas`; do perl -p -i -e 's/domain.old/domain.new/g' $i ; done
-
-perl -p -i -e 's/domain.old/domain.new/g' src/main/resources/kune.properties # or in /etc/kune
-perl -p -i -e 's/domain.old/domain.new/g' src/main/resources/wave-server.properties # or in /etc/kune
-perl -p -i -e 's/domain.old/domain.new/g' src/main/webapp/ws.html
-or in production
-perl -p -i -e 's/domain.old/domain.new/g' /var/www/kune/ws.html
-
-rename 's/domain.old/domain.new/g' /var/lib/kune/_accounts/*
-
-Remove old persisted sessions:
-rm /var/lib/kune/_sessions/*
-
-===Update the openfire configuration===
-Update your new domain in:
-Server > Server Manager > Edit Server Properties 
-Restart the openfire server 
-  /etc/init.d/openfire restart
-
-===Update your SMTP configuration (and MX record) ===
-So emails like someone at domain.new are propertly sended.
-
-===Certificates===
-Update your ssl certificates (openfire, wave keystore, wave federation, etc), if you have configured before with domain.old
-
-Restart kune and check if all it's ok.

Deleted: trunk/src/main/java/cc/kune/core/server/init/KuneJpaPersistModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/init/KuneJpaPersistModule.java	2012-03-07 12:19:26 UTC (rev 1746)
+++ trunk/src/main/java/cc/kune/core/server/init/KuneJpaPersistModule.java	2012-03-07 13:08:17 UTC (rev 1747)
@@ -1,5 +0,0 @@
-package cc.kune.core.server.init;
-
-public class KuneJpaPersistModule {
-
-}

Modified: trunk/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java	2012-03-07 12:19:26 UTC (rev 1746)
+++ trunk/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java	2012-03-07 13:08:17 UTC (rev 1747)
@@ -111,7 +111,6 @@
     // final KuneJpaLocalTxnInterceptor transactionInterceptor = new
     // KuneJpaLocalTxnInterceptor();
     // requestInjection(transactionInterceptor);
-    //
     // bindInterceptor(annotatedWith(KuneTransactional.class), any(),
     // transactionInterceptor);
     // bindInterceptor(any(), annotatedWith(KuneTransactional.class),

Copied: trunk/src/main/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java (from rev 1746, trunk/src/test/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java)
===================================================================
--- trunk/src/main/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java	                        (rev 0)
+++ trunk/src/main/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java	2012-03-07 13:08:17 UTC (rev 1747)
@@ -0,0 +1,171 @@
+/**
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * 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 com.google.inject.persist.jpa;
+
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+
+import cc.kune.core.server.persist.KuneTransactional;
+
+import com.google.inject.Inject;
+import com.google.inject.persist.UnitOfWork;
+
+/**
+ * @author Dhanji R. Prasanna (dhanji at gmail.com)
+ */
+public class KuneJpaLocalTxnInterceptor implements MethodInterceptor {
+
+  @KuneTransactional
+  private static class Internal {
+  }
+
+  // Tracks if the unit of work was begun implicitly by this transaction.
+  private final ThreadLocal<Boolean> didWeStartWork = new ThreadLocal<Boolean>();
+
+  @Inject
+  private final JpaPersistService emProvider = null;
+
+  @Inject
+  private final UnitOfWork unitOfWork = null;
+
+  @Override
+  public Object invoke(final MethodInvocation methodInvocation) throws Throwable {
+
+    // Should we start a unit of work?
+    if (!emProvider.isWorking()) {
+      emProvider.begin();
+      didWeStartWork.set(true);
+    }
+
+    final KuneTransactional transactional = readTransactionMetadata(methodInvocation);
+    final EntityManager em = this.emProvider.get();
+
+    // Allow 'joining' of transactions if there is an enclosing
+    // @KuneTransactional method.
+    if (em.getTransaction().isActive()) {
+      return methodInvocation.proceed();
+    }
+
+    final EntityTransaction txn = em.getTransaction();
+    txn.begin();
+
+    Object result;
+    try {
+      result = methodInvocation.proceed();
+
+    } catch (final Exception e) {
+      // commit transaction only if rollback didnt occur
+      if (rollbackIfNecessary(transactional, e, txn)) {
+        txn.commit();
+      }
+
+      // propagate whatever exception is thrown anyway
+      throw e;
+    } finally {
+      // Close the em if necessary (guarded so this code doesn't run unless
+      // catch fired).
+      if (null != didWeStartWork.get() && !txn.isActive()) {
+        didWeStartWork.remove();
+        unitOfWork.end();
+      }
+    }
+
+    // everything was normal so commit the txn (do not move into try block above
+    // as it
+    // interferes with the advised method's throwing semantics)
+    try {
+      txn.commit();
+    } finally {
+      // close the em if necessary
+      if (null != didWeStartWork.get()) {
+        didWeStartWork.remove();
+        unitOfWork.end();
+      }
+    }
+
+    // or return result
+    return result;
+  }
+
+  // TODO(dhanji): Cache this method's results.
+  private KuneTransactional readTransactionMetadata(final MethodInvocation methodInvocation) {
+    KuneTransactional transactional;
+    final Method method = methodInvocation.getMethod();
+    final Class<?> targetClass = methodInvocation.getThis().getClass();
+
+    transactional = method.getAnnotation(KuneTransactional.class);
+    if (null == transactional) {
+      // If none on method, try the class.
+      transactional = targetClass.getAnnotation(KuneTransactional.class);
+    }
+    if (null == transactional) {
+      // If there is no transactional annotation present, use the default
+      transactional = Internal.class.getAnnotation(KuneTransactional.class);
+    }
+
+    return transactional;
+  }
+
+  /**
+   * Returns True if rollback DID NOT HAPPEN (i.e. if commit should continue).
+   * 
+   * @param transactional
+   *          The metadata annotaiton of the method
+   * @param e
+   *          The exception to test for rollback
+   * @param txn
+   *          A JPA Transaction to issue rollbacks on
+   */
+  private boolean rollbackIfNecessary(final KuneTransactional transactional, final Exception e,
+      final EntityTransaction txn) {
+    boolean commit = true;
+
+    // check rollback clauses
+    for (final Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {
+
+      // if one matched, try to perform a rollback
+      if (rollBackOn.isInstance(e)) {
+        commit = false;
+
+        // check ignore clauses (supercedes rollback clause)
+        for (final Class<? extends Exception> exceptOn : transactional.ignore()) {
+          // An exception to the rollback clause was found, DON'T rollback
+          // (i.e. commit and throw anyway)
+          if (exceptOn.isInstance(e)) {
+            commit = true;
+            break;
+          }
+        }
+
+        // rollback only if nothing matched the ignore check
+        if (!commit) {
+          txn.rollback();
+        }
+        // otherwise continue to commit
+
+        break;
+      }
+    }
+
+    return commit;
+  }
+}

Deleted: trunk/src/test/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java
===================================================================
--- trunk/src/test/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java	2012-03-07 12:19:26 UTC (rev 1746)
+++ trunk/src/test/java/com/google/inject/persist/jpa/KuneJpaLocalTxnInterceptor.java	2012-03-07 13:08:17 UTC (rev 1747)
@@ -1,171 +0,0 @@
-/**
- * Copyright (C) 2010 Google, Inc.
- *
- * 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 com.google.inject.persist.jpa;
-
-import java.lang.reflect.Method;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-
-import cc.kune.core.server.persist.KuneTransactional;
-
-import com.google.inject.Inject;
-import com.google.inject.persist.UnitOfWork;
-
-/**
- * @author Dhanji R. Prasanna (dhanji at gmail.com)
- */
-public class KuneJpaLocalTxnInterceptor implements MethodInterceptor {
-
-  @KuneTransactional
-  private static class Internal {
-  }
-
-  // Tracks if the unit of work was begun implicitly by this transaction.
-  private final ThreadLocal<Boolean> didWeStartWork = new ThreadLocal<Boolean>();
-
-  @Inject
-  private final JpaPersistService emProvider = null;
-
-  @Inject
-  private final UnitOfWork unitOfWork = null;
-
-  @Override
-  public Object invoke(final MethodInvocation methodInvocation) throws Throwable {
-
-    // Should we start a unit of work?
-    if (!emProvider.isWorking()) {
-      emProvider.begin();
-      didWeStartWork.set(true);
-    }
-
-    final KuneTransactional transactional = readTransactionMetadata(methodInvocation);
-    final EntityManager em = this.emProvider.get();
-
-    // Allow 'joining' of transactions if there is an enclosing
-    // @KuneTransactional method.
-    if (em.getTransaction().isActive()) {
-      return methodInvocation.proceed();
-    }
-
-    final EntityTransaction txn = em.getTransaction();
-    txn.begin();
-
-    Object result;
-    try {
-      result = methodInvocation.proceed();
-
-    } catch (final Exception e) {
-      // commit transaction only if rollback didnt occur
-      if (rollbackIfNecessary(transactional, e, txn)) {
-        txn.commit();
-      }
-
-      // propagate whatever exception is thrown anyway
-      throw e;
-    } finally {
-      // Close the em if necessary (guarded so this code doesn't run unless
-      // catch fired).
-      if (null != didWeStartWork.get() && !txn.isActive()) {
-        didWeStartWork.remove();
-        unitOfWork.end();
-      }
-    }
-
-    // everything was normal so commit the txn (do not move into try block above
-    // as it
-    // interferes with the advised method's throwing semantics)
-    try {
-      txn.commit();
-    } finally {
-      // close the em if necessary
-      if (null != didWeStartWork.get()) {
-        didWeStartWork.remove();
-        unitOfWork.end();
-      }
-    }
-
-    // or return result
-    return result;
-  }
-
-  // TODO(dhanji): Cache this method's results.
-  private KuneTransactional readTransactionMetadata(final MethodInvocation methodInvocation) {
-    KuneTransactional transactional;
-    final Method method = methodInvocation.getMethod();
-    final Class<?> targetClass = methodInvocation.getThis().getClass();
-
-    transactional = method.getAnnotation(KuneTransactional.class);
-    if (null == transactional) {
-      // If none on method, try the class.
-      transactional = targetClass.getAnnotation(KuneTransactional.class);
-    }
-    if (null == transactional) {
-      // If there is no transactional annotation present, use the default
-      transactional = Internal.class.getAnnotation(KuneTransactional.class);
-    }
-
-    return transactional;
-  }
-
-  /**
-   * Returns True if rollback DID NOT HAPPEN (i.e. if commit should continue).
-   * 
-   * @param transactional
-   *          The metadata annotaiton of the method
-   * @param e
-   *          The exception to test for rollback
-   * @param txn
-   *          A JPA Transaction to issue rollbacks on
-   */
-  private boolean rollbackIfNecessary(final KuneTransactional transactional, final Exception e,
-      final EntityTransaction txn) {
-    boolean commit = true;
-
-    // check rollback clauses
-    for (final Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {
-
-      // if one matched, try to perform a rollback
-      if (rollBackOn.isInstance(e)) {
-        commit = false;
-
-        // check ignore clauses (supercedes rollback clause)
-        for (final Class<? extends Exception> exceptOn : transactional.ignore()) {
-          // An exception to the rollback clause was found, DON'T rollback
-          // (i.e. commit and throw anyway)
-          if (exceptOn.isInstance(e)) {
-            commit = true;
-            break;
-          }
-        }
-
-        // rollback only if nothing matched the ignore check
-        if (!commit) {
-          txn.rollback();
-        }
-        // otherwise continue to commit
-
-        break;
-      }
-    }
-
-    return commit;
-  }
-}




More information about the kune-commits mailing list