Removing the org.jboss compatibility classes

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17912 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2009-11-04 18:40:13 +00:00
parent 66610a567c
commit ecaf3990b8
16 changed files with 41 additions and 476 deletions

View File

@ -36,7 +36,6 @@
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.jboss.envers.*;
/**
* A helper class to read versioning meta-data from annotations on a persistent class.
@ -69,12 +68,7 @@ private ModificationStore getDefaultAudited(XClass clazz) {
if (defaultAudited != null) {
return defaultAudited.modStore();
} else {
Versioned defaultVersioned = clazz.getAnnotation(Versioned.class);
if (defaultVersioned != null) {
return ModificationStore.FULL;
} else {
return null;
}
return null;
}
}

View File

@ -26,7 +26,6 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
import org.hibernate.MappingException;
import org.jboss.envers.Versioned;
/**
* Reads persistent properties form a
@ -157,12 +156,9 @@ private boolean fillPropertyData(XProperty property, PropertyAuditingData proper
// Checking if this property is explicitly audited or if all properties are.
Audited aud = property.getAnnotation(Audited.class);
Versioned ver = property.getAnnotation(Versioned.class);
if (aud != null) {
propertyData.setStore(aud.modStore());
propertyData.setRelationTargetAuditMode(aud.targetAuditMode());
} else if (ver != null) {
propertyData.setStore(ModificationStore.FULL);
} else {
if (defaultStore != null) {
propertyData.setStore(defaultStore);

View File

@ -23,13 +23,15 @@
*/
package org.hibernate.envers.exception;
import org.jboss.envers.exception.VersionsException;
import org.hibernate.HibernateException;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class AuditException extends VersionsException {
public AuditException(String message) {
public class AuditException extends HibernateException {
private static final long serialVersionUID = 4306480965630972168L;
public AuditException(String message) {
super(message);
}

View File

@ -23,13 +23,20 @@
*/
package org.hibernate.envers.exception;
import org.jboss.envers.exception.NotVersionedException;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class NotAuditedException extends NotVersionedException {
public NotAuditedException(String entityName, String message) {
super(entityName, message);
public class NotAuditedException extends AuditException {
private static final long serialVersionUID = 4809674577449455510L;
private final String entityName;
public NotAuditedException(String entityName, String message) {
super(message);
this.entityName = entityName;
}
public String getEntityName() {
return entityName;
}
}

View File

@ -28,12 +28,27 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionDoesNotExistException extends org.jboss.envers.exception.RevisionDoesNotExistException {
public RevisionDoesNotExistException(Number revision) {
super(revision);
public class RevisionDoesNotExistException extends AuditException {
private static final long serialVersionUID = -6417768274074962282L;
private Number revision;
private Date date;
public RevisionDoesNotExistException(Number revision) {
super("Revision " + revision + " does not exist.");
this.revision = revision;
}
public RevisionDoesNotExistException(Date date) {
super(date);
super("There is no revision before or at " + date + ".");
this.date = date;
}
public Number getRevision() {
return revision;
}
public Date getDate() {
return date;
}
}

View File

@ -32,6 +32,7 @@
import org.hibernate.envers.exception.RevisionDoesNotExistException;
import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.query.AuditQueryCreator;
import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
import org.hibernate.envers.synchronization.AuditSync;
@ -41,7 +42,6 @@
import org.hibernate.Session;
import org.hibernate.event.EventSource;
import org.hibernate.engine.SessionImplementor;
import org.jboss.envers.query.VersionsQueryCreator;
/**
* @author Adam Warski (adam at warski dot org)
@ -205,7 +205,7 @@ public <T> T getCurrentRevision(Class<T> revisionEntityClass, boolean persist) {
return (T) auditSync.getCurrentRevisionData(session, persist);
}
public VersionsQueryCreator createQuery() {
return new VersionsQueryCreator(verCfg, this);
public AuditQueryCreator createQuery() {
return new AuditQueryCreator(verCfg, this);
}
}

View File

@ -27,13 +27,12 @@
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
import org.jboss.envers.VersionsReader;
/**
* An interface exposed by a VersionsReader to library-facing classes.
* @author Adam Warski (adam at warski dot org)
*/
public interface AuditReaderImplementor extends AuditReader, VersionsReader {
public interface AuditReaderImplementor extends AuditReader {
SessionImplementor getSessionImplementor();
Session getSession();
FirstLevelCache getFirstLevelCache();

View File

@ -1,34 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
/**
* @see org.hibernate.envers.ModificationStore
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public enum ModificationStore {
FULL
}

View File

@ -1,41 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @see org.hibernate.envers.Audited
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
public @interface Versioned {
public abstract ModificationStore modStore() default ModificationStore.FULL;
}

View File

@ -1,57 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import org.hibernate.envers.AuditReader;
import org.jboss.envers.query.VersionsQueryCreator;
import org.jboss.envers.exception.NotVersionedException;
import org.jboss.envers.exception.RevisionDoesNotExistException;
import java.util.List;
import java.util.Date;
/**
* @see org.hibernate.envers.AuditReader
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public interface VersionsReader extends AuditReader {
<T> T find(Class<T> cls, Object primaryKey, Number revision) throws
IllegalArgumentException, NotVersionedException, IllegalStateException;
List<Number> getRevisions(Class<?> cls, Object primaryKey)
throws IllegalArgumentException, NotVersionedException, IllegalStateException;
Date getRevisionDate(Number revision) throws IllegalArgumentException, RevisionDoesNotExistException,
IllegalStateException;
Number getRevisionNumberForDate(Date date) throws IllegalStateException, RevisionDoesNotExistException,
IllegalArgumentException;
<T> T findRevision(Class<T> revisionEntityClass, Number revision) throws IllegalArgumentException,
RevisionDoesNotExistException, IllegalStateException;
VersionsQueryCreator createQuery();
}

View File

@ -1,96 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import javax.persistence.EntityManager;
import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.envers.reader.AuditReaderImpl;
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventListeners;
import org.hibernate.event.PostInsertEventListener;
import org.jboss.envers.exception.VersionsException;
/**
* @see org.hibernate.envers.AuditReaderFactory
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsReaderFactory {
private VersionsReaderFactory() { }
/**
* Create a versions reader associated with an open session.
* <b>WARNING:</b> Using Envers with Hibernate (not with Hibernate Entity Manager/JPA) is experimental,
* if possible, use {@link VersionsReaderFactory#get(javax.persistence.EntityManager)}.
* @param session An open session.
* @return A versions reader associated with the given sesison. It shouldn't be used
* after the session is closed.
* @throws org.hibernate.envers.exception.AuditException When the given required listeners aren't installed.
*/
public static VersionsReader get(Session session) throws VersionsException {
SessionImplementor sessionImpl = (SessionImplementor) session;
EventListeners listeners = sessionImpl.getListeners();
for (PostInsertEventListener listener : listeners.getPostInsertEventListeners()) {
if (listener instanceof AuditEventListener) {
if (arrayIncludesInstanceOf(listeners.getPostUpdateEventListeners(), AuditEventListener.class) &&
arrayIncludesInstanceOf(listeners.getPostDeleteEventListeners(), AuditEventListener.class)) {
return new AuditReaderImpl(((AuditEventListener) listener).getVerCfg(), session,
sessionImpl);
}
}
}
throw new VersionsException("You need install the org.hibernate.envers.event.VersionsEventListener " +
"class as post insert, update and delete event listener.");
}
/**
* Create a versions reader associated with an open entity manager.
* @param entityManager An open entity manager.
* @return A versions reader associated with the given entity manager. It shouldn't be used
* after the entity manager is closed.
* @throws org.hibernate.envers.exception.AuditException When the given entity manager is not based on Hibernate, or if the required
* listeners aren't installed.
*/
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
if (entityManager.getDelegate() instanceof Session) {
return get((Session) entityManager.getDelegate());
}
if (entityManager.getDelegate() instanceof EntityManager) {
if (entityManager.getDelegate() instanceof Session) {
return get((Session) entityManager.getDelegate());
}
}
throw new VersionsException("Hibernate EntityManager not present!");
}
}

View File

@ -1,34 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.event;
import org.hibernate.envers.event.AuditEventListener;
/**
* @see AuditEventListener
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsEventListener extends AuditEventListener { }

View File

@ -1,45 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.exception;
import org.hibernate.envers.exception.AuditException;
/**
* @see org.hibernate.envers.exception.NotAuditedException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class NotVersionedException extends VersionsException {
private final String entityName;
public NotVersionedException(String entityName, String message) {
super(message);
this.entityName = entityName;
}
public String getEntityName() {
return entityName;
}
}

View File

@ -1,55 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.exception;
import java.util.Date;
/**
* @see org.hibernate.envers.exception.RevisionDoesNotExistException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionDoesNotExistException extends VersionsException {
private Number revision;
private Date date;
public RevisionDoesNotExistException(Number revision) {
super("Revision " + revision + " does not exist.");
this.revision = revision;
}
public RevisionDoesNotExistException(Date date) {
super("There is no revision before or at " + date + ".");
this.date = date;
}
public Number getRevision() {
return revision;
}
public Date getDate() {
return date;
}
}

View File

@ -1,46 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.exception;
import org.hibernate.HibernateException;
/**
* @see org.hibernate.envers.exception.AuditException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsException extends HibernateException {
public VersionsException(String message) {
super(message);
}
public VersionsException(String message, Throwable cause) {
super(message, cause);
}
public VersionsException(Throwable cause) {
super(cause);
}
}

View File

@ -1,40 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.query;
import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.query.AuditQueryCreator;
import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* @link AuditQueryCreator
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsQueryCreator extends AuditQueryCreator {
public VersionsQueryCreator(AuditConfiguration verCfg, AuditReaderImplementor versionsReaderImplementor) {
super(verCfg, versionsReaderImplementor);
}
}