Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' into refactor-filterconstraints
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Jul 9, 2013
2 parents d06f598 + c65bb7c commit 03e6f63
Show file tree
Hide file tree
Showing 25 changed files with 360 additions and 338 deletions.
1 change: 1 addition & 0 deletions functional-test/sample-projects/glossary/pom.xml
Expand Up @@ -13,6 +13,7 @@
</configuration>
<groupId>org.zanata</groupId>
<artifactId>zanata-maven-plugin</artifactId>
<version>${zanata.client.version}</version>
</plugin>
</plugins>
</build>
Expand Down
3 changes: 2 additions & 1 deletion functional-test/sample-projects/plural/pom.xml
Expand Up @@ -9,7 +9,8 @@
<plugin>
<groupId>org.zanata</groupId>
<artifactId>zanata-maven-plugin</artifactId>
<configuration>
<version>${zanata.client.version}</version>
<configuration>
<srcDir>pot</srcDir>
<transDir>.</transDir>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -35,7 +35,7 @@
<zanata.api.version>3.0.1-SNAPSHOT</zanata.api.version>
<!-- This should always be the previous version of the used api version above -->
<zanata.api.compat.version>3.0.1-SNAPSHOT</zanata.api.compat.version>
<zanata.client.version>3.0.0</zanata.client.version>
<zanata.client.version>3.0.1-SNAPSHOT</zanata.client.version>
<zanata.common.version>3.0.0</zanata.common.version>

<richfaces.version>4.3.2.Final</richfaces.version>
Expand Down
44 changes: 0 additions & 44 deletions zanata-model/pom.xml
Expand Up @@ -251,48 +251,4 @@

</dependencies>

<profiles>
<profile>
<id>mysql</id>
<properties>
<env.dbunit.type>MYSQL</env.dbunit.type>
<ds.jndi.name>zanataDatasource</ds.jndi.name>
<ds.hibernate.dialect>org.zanata.ZanataMySQL5InnoDBDialect</ds.hibernate.dialect>
<ds.driver.class>com.mysql.jdbc.Driver</ds.driver.class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<persistenceunit>zanataDatabase</persistenceunit>
<outputfilename>schema.ddl</outputfilename>
<drop>false</drop>
<create>true</create>
<export>false</export>
<format>true</format>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Expand Up @@ -42,12 +42,12 @@ public class SimpleSourceContents implements SourceContents
{
private final String qualifiedId;
private final Map<LocaleId, TargetContents> targets;
private final LocaleId locale;
private final @Nonnull LocaleId locale;
private List<String> contents;

public SimpleSourceContents(String qualifiedId,
Map<LocaleId, TargetContents> targets,
LocaleId locale,
@Nonnull LocaleId locale,
List<String> contents)
{
this.qualifiedId = qualifiedId;
Expand All @@ -57,7 +57,7 @@ public SimpleSourceContents(String qualifiedId,
}

public SimpleSourceContents(String qualifiedId,
LocaleId locale,
@Nonnull LocaleId locale,
@Nonnull String content0,
Map<LocaleId, TargetContents> targets)
{
Expand All @@ -66,7 +66,7 @@ public SimpleSourceContents(String qualifiedId,

public SimpleSourceContents(String qualifiedId,
Map<LocaleId, TargetContents> targets,
LocaleId locale,
@Nonnull LocaleId locale,
@Nonnull String... contents)
{
this(qualifiedId, targets, locale, ImmutableList.copyOf(contents));
Expand Down
11 changes: 7 additions & 4 deletions zanata-model/src/main/java/org/zanata/model/SourceContents.java
Expand Up @@ -21,6 +21,9 @@

package org.zanata.model;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.zanata.common.HasContents;
import org.zanata.common.LocaleId;

Expand All @@ -30,18 +33,18 @@
*/
public interface SourceContents extends HasContents
{
public LocaleId getLocale();
public String getQualifiedId();
public @Nonnull LocaleId getLocale();
public @Nonnull String getQualifiedId();
/**
* Gets the TargetContents for a single locale.
* Note that default implementation in HTextFlow requires a lot of database I/O
* @param localeId
* @return
*/
public TargetContents getTargetContents(LocaleId localeId);
public @Nullable TargetContents getTargetContents(@Nonnull LocaleId localeId);
/**
* Gets the TargetContents for all available locales.
* @return
*/
public Iterable<TargetContents> getAllTargetContents();
public @Nonnull Iterable<TargetContents> getAllTargetContents();
}
99 changes: 1 addition & 98 deletions zanata-war/pom.xml
Expand Up @@ -489,53 +489,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<export>false</export>
<update>false</update>
<drop>false</drop>
<create>false</create>
<outputfilename>schema.ddl</outputfilename>
<persistenceunit>zanataTestDatasourcePU</persistenceunit>
</componentProperties>
</configuration>
<!--
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
-->
<dependencies>
<!--
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.170</version>
</dependency>
</dependencies>
</plugin>


<!--
This is to make the GWT plugin happy (http://code.google.com/p/google-web-toolkit/issues/detail?id=4600).
Taken from https://issues.sonatype.org/browse/MNGECLIPSE-864?focusedCommentId=148457&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-148457
Expand Down Expand Up @@ -905,7 +858,7 @@

<profile>
<!-- This profile tells GWT to use an alternative GWT module which has
only one permutation, and to compile in draft mode -->
only two permutations, and to compile in draft mode -->
<id>chromefirefox</id>
<properties>
<zanata.gwt.module>org.zanata.webtrans.ApplicationChromeFirefox</zanata.gwt.module>
Expand All @@ -924,56 +877,6 @@
</build>
</profile>

<profile>
<id>eclipse</id>
<build>
<finalName>zanata-dev</finalName>
<resources>
<resource>
<directory>src/main/resources-dev</directory>
<filtering>false</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>2.0</wtpversion>

<additionalBuildcommands>
<buildCommand>
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
</buildCommand>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
</buildCommand>
</additionalBuildcommands>

<additionalProjectnatures>
<projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
<projectnature>com.google.gdt.eclipse.core.webAppNature</projectnature>
</additionalProjectnatures>

<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>com.google.gwt.eclipse.core.GWT_CONTAINER</classpathContainer>
</classpathContainers>
<excludes>
<!-- These are provided by the GWT container -->
<exclude>com.google.gwt:gwt-servlet</exclude>
<exclude>com.google.gwt:gwt-user</exclude>
</excludes>
</configuration>
</plugin>

</plugins>

</build>
</profile>

<profile>
<id>it-coverage</id>
<!-- In order to combine unit test and integration test coverage together, it requires below two commands:
Expand Down
Expand Up @@ -19,21 +19,24 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.zanata.jdbc;
package org.zanata.database;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Set;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang.ClassUtils;
import org.testng.internal.annotations.Sets;

/**
Expand All @@ -42,7 +45,7 @@
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Slf4j
public class ConnectionWrapper implements InvocationHandler
class ConnectionWrapper implements InvocationHandler
{
// For reference, this is what the mysql exception looks like:
// Streaming result set com.mysql.jdbc.RowDataDynamic@1950740 is
Expand All @@ -55,15 +58,27 @@ public class ConnectionWrapper implements InvocationHandler
private Set<Throwable> resultSetsOpened = Sets.newHashSet();
private Throwable streamingResultSetOpened;

public static Connection wrap(Connection connection)
public static Connection wrap(Connection connection)
{
if (Proxy.isProxyClass(connection.getClass()) && Proxy.getInvocationHandler(connection) instanceof ConnectionWrapper)
{
return connection;
}
ConnectionWrapper h = new ConnectionWrapper(connection);
ClassLoader cl = h.getClass().getClassLoader();
return (Connection) Proxy.newProxyInstance(cl, connection.getClass().getInterfaces(), h);
return ProxyUtil.newProxy(connection, new ConnectionWrapper(connection));
}

public static Connection wrapUnlessMysql(Connection connection) throws SQLException
{
DatabaseMetaData metaData = connection.getMetaData();
String databaseName = metaData.getDatabaseProductName();
if ("MySQL".equals(databaseName))
{
return connection;
}
else
{
return wrap(connection);
}
}

/**
Expand Down
46 changes: 46 additions & 0 deletions zanata-war/src/main/java/org/zanata/database/ProxyUtil.java
@@ -0,0 +1,46 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.zanata.database;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.List;

import org.apache.commons.lang.ClassUtils;

/**
* @author Sean Flanigan <a href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
class ProxyUtil
{

public static <T> T newProxy(T object, InvocationHandler handler)
{
Class<?> clazz = object.getClass();
ClassLoader cl = clazz.getClassLoader();
List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(clazz);
Class<?>[] interfaces = allInterfaces.toArray(new Class<?>[0]);
return (T) Proxy.newProxyInstance(cl, interfaces, handler);
}

}

0 comments on commit 03e6f63

Please sign in to comment.