You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/16 16:41:29 UTC
svn commit: r695923 - in /labs/magma/trunk/database-jpa-web: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/magma/ src/main/java/org/apache/magma/database/
src/main/java/org/apache/magma/database/...
Author: simoneg
Date: Tue Sep 16 07:41:29 2008
New Revision: 695923
URL: http://svn.apache.org/viewvc?rev=695923&view=rev
Log:
Initial import.
Added:
labs/magma/trunk/database-jpa-web/pom.xml
labs/magma/trunk/database-jpa-web/src/
labs/magma/trunk/database-jpa-web/src/main/
labs/magma/trunk/database-jpa-web/src/main/java/
labs/magma/trunk/database-jpa-web/src/main/java/org/
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/CloseTransactions.aj
labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/UseSameDatabase.aj
Added: labs/magma/trunk/database-jpa-web/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-jpa-web/pom.xml?rev=695923&view=auto
==============================================================================
--- labs/magma/trunk/database-jpa-web/pom.xml (added)
+++ labs/magma/trunk/database-jpa-web/pom.xml Tue Sep 16 07:41:29 2008
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>magma-parent</artifactId>
+ <groupId>org.apache.magma</groupId>
+ <version>1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>database-jpa-web</artifactId>
+ <name>Database JPA for Web</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>magma</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.magma.tools</groupId>
+ <artifactId>maven-magma-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+ <description/>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>database-jpa</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>foundation-website</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Added: labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/CloseTransactions.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/CloseTransactions.aj?rev=695923&view=auto
==============================================================================
--- labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/CloseTransactions.aj (added)
+++ labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/CloseTransactions.aj Tue Sep 16 07:41:29 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.magma.database.openjpa;
+
+import java.util.Set;
+import org.apache.magma.website.Dispatch;
+
+/**
+ * Closes all {@link JPADatabase}s and relative transactions at the end of a get/post.
+ * @author Simone Gianni <si...@apache.org>
+ */
+public aspect CloseTransactions {
+
+ pointcut servletHandling() : execution(* Dispatch.handle(..));
+
+ after() returning : servletHandling() {
+ Set<JPADatabase> dbs = JPADatabasesRegistry.get();
+ if (dbs == null) return;
+ for (JPADatabase db : dbs) {
+ try {
+ db.commit();
+ } finally {
+ JPADatabasesRegistry.remove(db);
+ }
+ }
+ }
+
+ after() throwing : servletHandling() {
+ Set<JPADatabase> dbs = JPADatabasesRegistry.get();
+ if (dbs == null) return;
+ for (JPADatabase db : dbs) {
+ try {
+ db.rollback();
+ } finally {
+ JPADatabasesRegistry.remove(db);
+ }
+ }
+ }
+}
Added: labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/UseSameDatabase.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/UseSameDatabase.aj?rev=695923&view=auto
==============================================================================
--- labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/UseSameDatabase.aj (added)
+++ labs/magma/trunk/database-jpa-web/src/main/java/org/apache/magma/database/openjpa/UseSameDatabase.aj Tue Sep 16 07:41:29 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.magma.database.openjpa;
+
+import org.apache.magma.website.Dispatch;
+import org.apache.magma.database.Database;
+
+/**
+ * Forces every get/post to use only one instance of the JPADatabase.
+ * @author Simone Gianni <si...@apache.org>
+ */
+public aspect UseSameDatabase percflow(servletHandling()) {
+
+ declare precedence : UseSameDatabase, InstallJPADatabase, *;
+
+ pointcut servletHandling() : execution(* Dispatch.handle(..));
+
+ private Database currentdb = null;
+
+ Database around() : InstallJPADatabase.databaseCreation() {
+ if (currentdb == null) {
+ currentdb = proceed();
+ }
+ return currentdb;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org