Author: adamw
Date: 2008-08-17 10:24:36 -0400 (Sun, 17 Aug 2008)
New Revision: 113
Added:
trunk/src/main/org/jboss/envers/entities/EntityInstantiator.java
trunk/src/main/org/jboss/envers/entities/RevisionTypeType.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/
Removed:
trunk/src/main/org/jboss/envers/entity/
Modified:
trunk/src/main/org/jboss/envers/configuration/RevisionInfoConfiguration.java
trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
trunk/src/main/org/jboss/envers/configuration/metadata/VersionsMetadataGenerator.java
trunk/src/main/org/jboss/envers/entities/IdMappingData.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/OneToManyIdMapper.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/ToOneIdMapper.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/AbstractDelegateSessionImplementor.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/OneToManyInitializor.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/CollectionProxy.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/Initializor.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/ListProxy.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/SetProxy.java
trunk/src/main/org/jboss/envers/query/impl/AbstractVersionsQuery.java
trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
trunk/src/main/org/jboss/envers/query/order/RevisionVersionsOrder.java
trunk/src/main/org/jboss/envers/query/projection/DistinctVersionsProjection.java
trunk/src/main/org/jboss/envers/query/projection/ProjectionWrapper.java
trunk/src/main/org/jboss/envers/query/projection/RevisionVersionsProjection.java
trunk/src/main/org/jboss/envers/query/projection/VersionsProjectionList.java
trunk/src/main/org/jboss/envers/revisioninfo/CustomRevisionInfoGenerator.java
trunk/src/main/org/jboss/envers/revisioninfo/DefaultRevisionInfoGenerator.java
trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java
trunk/src/main/org/jboss/envers/tools/graph/Vertex.java
trunk/src/main/org/jboss/envers/tools/log/YLog.java
trunk/src/main/org/jboss/envers/tools/log/YLogManager.java
trunk/src/main/org/jboss/envers/tools/reflection/YClass.java
trunk/src/main/org/jboss/envers/tools/reflection/YMethodsAndClasses.java
trunk/src/main/org/jboss/envers/tools/reflection/YProperty.java
trunk/src/main/org/jboss/envers/tools/reflection/YReflectionManager.java
Log:
ENVERS-37: moving packages to more logical places, adding final to variables
Modified: trunk/src/main/org/jboss/envers/configuration/RevisionInfoConfiguration.java
===================================================================
---
trunk/src/main/org/jboss/envers/configuration/RevisionInfoConfiguration.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/configuration/RevisionInfoConfiguration.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -170,10 +170,6 @@
revisionInfoXmlMapping,
new RevisionInfoQueryCreator(revisionInfoEntityName, revisionInfoIdName,
revisionInfoTimestampName));
}
-
- public boolean isRevisionInfoEntityName(String entityName) {
- return revisionInfoEntityName.equals(entityName);
- }
}
class RevisionInfoConfigurationResult {
Modified: trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -52,7 +52,6 @@
private final VersionsEntitiesConfiguration verEntCfg;
private final VersionsSyncManager versionsSyncManager;
private final EntitiesConfigurations entCfg;
- private final RevisionInfoConfiguration revInfoCfg;
private final RevisionInfoQueryCreator revisionInfoQueryCreator;
public VersionsEntitiesConfiguration getVerEntCfg() {
@@ -63,10 +62,6 @@
return versionsSyncManager;
}
- public RevisionInfoConfiguration getRevInfoCfg() {
- return revInfoCfg;
- }
-
public GlobalConfiguration getGlobalCfg() {
return globalCfg;
}
@@ -92,7 +87,7 @@
Properties properties = cfg.getProperties();
YReflectionManager reflectionManager = getReflectionManager(cfg);
- revInfoCfg = new RevisionInfoConfiguration();
+ RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration();
RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg,
reflectionManager);
verEntCfg = new VersionsEntitiesConfiguration(properties,
revInfoCfgResult.getRevisionPropType());
globalCfg = new GlobalConfiguration(properties);
Modified:
trunk/src/main/org/jboss/envers/configuration/metadata/VersionsMetadataGenerator.java
===================================================================
---
trunk/src/main/org/jboss/envers/configuration/metadata/VersionsMetadataGenerator.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/configuration/metadata/VersionsMetadataGenerator.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -591,7 +591,7 @@
// Adding the "revision type" property
Element revTypeProperty = MetadataTools.addProperty(class_mapping,
verCfg.getVerEntCfg().getRevisionTypePropName(),
verCfg.getVerEntCfg().getRevisionTypePropType(), false);
- revTypeProperty.addAttribute("type",
"org.jboss.envers.entity.RevisionTypeType");
+ revTypeProperty.addAttribute("type",
"org.jboss.envers.entities.RevisionTypeType");
break;
case SINGLE:
Copied: trunk/src/main/org/jboss/envers/entities/EntityInstantiator.java (from rev 112,
trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java)
===================================================================
--- trunk/src/main/org/jboss/envers/entities/EntityInstantiator.java
(rev 0)
+++ trunk/src/main/org/jboss/envers/entities/EntityInstantiator.java 2008-08-17 14:24:36
UTC (rev 113)
@@ -0,0 +1,90 @@
+/*
+ * Envers.
http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.entities;
+
+import org.jboss.envers.exception.VersionsException;
+import org.jboss.envers.configuration.VersionsConfiguration;
+import org.jboss.envers.entities.mapper.id.IdMapper;
+import org.jboss.envers.reader.VersionsReaderImplementor;
+import org.jboss.envers.tools.reflection.ReflectionTools;
+
+import java.util.Map;
+import java.util.List;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class EntityInstantiator {
+ private final VersionsConfiguration verCfg;
+ private final VersionsReaderImplementor versionsReader;
+
+ public EntityInstantiator(VersionsConfiguration verCfg, VersionsReaderImplementor
versionsReader) {
+ this.verCfg = verCfg;
+ this.versionsReader = versionsReader;
+ }
+
+ /**
+ * Creates an entity instance based on an entry from the versions table.
+ * @param entityName Name of the entity, which instances should be read
+ * @param versionsEntity An entry in the versions table, from which data should be
mapped.
+ * @param revision Revision at which this entity was read.
+ * @return An entity instance, with versioned properties set as in the versionsEntity
map, and proxies
+ * created for collections.
+ */
+ public Object createInstanceFromVersionsEntity(String entityName, Map versionsEntity,
Number revision) {
+ if (versionsEntity == null) {
+ return null;
+ }
+
+ // The $type$ property holds the name of the (versions) entity
+ String type = verCfg.getEntCfg().getEntityNameForVersionsEntityName((String)
versionsEntity.get("$type$"));
+
+ if (type != null) {
+ entityName = type;
+ }
+
+ Object ret;
+ try {
+ Class<?> cls = ReflectionTools.loadClass(entityName);
+ ret = cls.newInstance();
+ } catch (Exception e) {
+ throw new VersionsException(e);
+ }
+
+ IdMapper idMapper = verCfg.getEntCfg().getIdMapper(entityName);
+ Map originalId = (Map)
versionsEntity.get(verCfg.getVerEntCfg().getOriginalIdPropName());
+
+ Object primaryKey = idMapper.mapToIdFromMap(originalId);
+
+ verCfg.getEntCfg().getPropertyMapper(entityName).mapToEntityFromMap(ret,
versionsEntity, primaryKey, versionsReader, revision);
+ idMapper.mapToEntityFromMap(ret, originalId);
+
+ return ret;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void addInstancesFromVersionsEntities(String entityName, List list,
List<Map> versionsEntities, Number revision) {
+ for (Map versionsEntity : versionsEntities) {
+ list.add(createInstanceFromVersionsEntity(entityName, versionsEntity,
revision));
+ }
+ }
+}
Modified: trunk/src/main/org/jboss/envers/entities/IdMappingData.java
===================================================================
--- trunk/src/main/org/jboss/envers/entities/IdMappingData.java 2008-08-16 17:42:15 UTC
(rev 112)
+++ trunk/src/main/org/jboss/envers/entities/IdMappingData.java 2008-08-17 14:24:36 UTC
(rev 113)
@@ -28,11 +28,11 @@
* @author Adam Warski (adam at warski dot org)
*/
public class IdMappingData {
- private IdMapper idMapper;
+ private final IdMapper idMapper;
// Mapping which will be used to generate the entity
- private Element xmlMapping;
+ private final Element xmlMapping;
// Mapping which will be used to generate references to the entity in related
entities
- private Element xmlRelationMapping;
+ private final Element xmlRelationMapping;
public IdMappingData(IdMapper idMapper, Element xmlMapping, Element
xmlRelationMapping) {
this.idMapper = idMapper;
Copied: trunk/src/main/org/jboss/envers/entities/RevisionTypeType.java (from rev 111,
trunk/src/main/org/jboss/envers/entity/RevisionTypeType.java)
===================================================================
--- trunk/src/main/org/jboss/envers/entities/RevisionTypeType.java
(rev 0)
+++ trunk/src/main/org/jboss/envers/entities/RevisionTypeType.java 2008-08-17 14:24:36 UTC
(rev 113)
@@ -0,0 +1,85 @@
+package org.jboss.envers.entities;
+
+import org.hibernate.usertype.UserType;
+import org.hibernate.HibernateException;
+import org.jboss.envers.RevisionType;
+
+import java.sql.ResultSet;
+import java.sql.Types;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.io.Serializable;
+
+/**
+ * A hibernate type for the {@link RevisionType} enum.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionTypeType implements UserType {
+ private static final int[] SQL_TYPES = { Types.TINYINT };
+
+ public int[] sqlTypes() {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass() {
+ return RevisionType.class;
+ }
+
+ public RevisionType nullSafeGet(ResultSet resultSet, String[] names, Object owner)
throws HibernateException, SQLException {
+ byte representation = (byte) resultSet.getInt(names[0]);
+ RevisionType result = null;
+
+ if (!resultSet.wasNull()) {
+ result = RevisionType.fromRepresentation(representation);
+ }
+
+ return result;
+ }
+
+ public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index)
throws HibernateException, SQLException {
+ if (null == value) {
+ preparedStatement.setNull(index, Types.TINYINT);
+ } else {
+ preparedStatement.setInt(index, ((RevisionType) value).getRepresentation());
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException{
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
{
+ return cached;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable)value;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws
HibernateException {
+ return original;
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ //noinspection ObjectEquality
+ if (x == y) {
+ return true;
+ }
+
+ if (null == x || null == y) {
+ return false;
+ }
+
+ return x.equals(y);
+ }
+}
+
+
Modified: trunk/src/main/org/jboss/envers/entities/mapper/relation/OneToManyIdMapper.java
===================================================================
---
trunk/src/main/org/jboss/envers/entities/mapper/relation/OneToManyIdMapper.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/OneToManyIdMapper.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -23,9 +23,9 @@
import org.jboss.envers.entities.mapper.PropertyMapper;
import org.jboss.envers.reader.VersionsReaderImplementor;
-import org.jboss.envers.reader.lazy.OneToManyInitializor;
-import org.jboss.envers.reader.lazy.proxy.ListProxy;
-import org.jboss.envers.reader.lazy.proxy.SetProxy;
+import org.jboss.envers.entities.mapper.relation.lazy.OneToManyInitializor;
+import org.jboss.envers.entities.mapper.relation.lazy.proxy.ListProxy;
+import org.jboss.envers.entities.mapper.relation.lazy.proxy.SetProxy;
import org.jboss.envers.exception.VersionsException;
import org.jboss.envers.tools.reflection.ReflectionTools;
import org.hibernate.property.Setter;
Modified: trunk/src/main/org/jboss/envers/entities/mapper/relation/ToOneIdMapper.java
===================================================================
--- trunk/src/main/org/jboss/envers/entities/mapper/relation/ToOneIdMapper.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/entities/mapper/relation/ToOneIdMapper.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -26,7 +26,7 @@
import org.jboss.envers.tools.Tools;
import org.jboss.envers.tools.reflection.ReflectionTools;
import org.jboss.envers.reader.VersionsReaderImplementor;
-import org.jboss.envers.reader.lazy.ToOneDelegateSessionImplementor;
+import org.jboss.envers.entities.mapper.relation.lazy.ToOneDelegateSessionImplementor;
import org.hibernate.property.Setter;
import java.util.Map;
Copied: trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy (from rev 111,
trunk/src/main/org/jboss/envers/reader/lazy)
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/AbstractDelegateSessionImplementor.java
===================================================================
---
trunk/src/main/org/jboss/envers/reader/lazy/AbstractDelegateSessionImplementor.java 2008-08-16
17:39:05 UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/AbstractDelegateSessionImplementor.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy;
+package org.jboss.envers.entities.mapper.relation.lazy;
import org.hibernate.engine.*;
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/OneToManyInitializor.java
===================================================================
--- trunk/src/main/org/jboss/envers/reader/lazy/OneToManyInitializor.java 2008-08-16
17:39:05 UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/OneToManyInitializor.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,10 +19,10 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy;
+package org.jboss.envers.entities.mapper.relation.lazy;
import org.jboss.envers.reader.VersionsReaderImplementor;
-import org.jboss.envers.reader.lazy.proxy.Initializor;
+import org.jboss.envers.entities.mapper.relation.lazy.proxy.Initializor;
import org.jboss.envers.query.VersionsRestrictions;
import org.jboss.envers.exception.VersionsException;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java
===================================================================
---
trunk/src/main/org/jboss/envers/reader/lazy/ToOneDelegateSessionImplementor.java 2008-08-16
17:39:05 UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy;
+package org.jboss.envers.entities.mapper.relation.lazy;
import org.hibernate.HibernateException;
import org.jboss.envers.reader.VersionsReaderImplementor;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/CollectionProxy.java
===================================================================
--- trunk/src/main/org/jboss/envers/reader/lazy/proxy/CollectionProxy.java 2008-08-16
17:39:05 UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/CollectionProxy.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy.proxy;
+package org.jboss.envers.entities.mapper.relation.lazy.proxy;
import java.util.Collection;
import java.util.Iterator;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/Initializor.java
===================================================================
--- trunk/src/main/org/jboss/envers/reader/lazy/proxy/Initializor.java 2008-08-16 17:39:05
UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/Initializor.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy.proxy;
+package org.jboss.envers.entities.mapper.relation.lazy.proxy;
import java.util.Collection;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/ListProxy.java
===================================================================
--- trunk/src/main/org/jboss/envers/reader/lazy/proxy/ListProxy.java 2008-08-16 17:39:05
UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/ListProxy.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy.proxy;
+package org.jboss.envers.entities.mapper.relation.lazy.proxy;
import java.util.List;
import java.util.Collection;
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/SetProxy.java
===================================================================
--- trunk/src/main/org/jboss/envers/reader/lazy/proxy/SetProxy.java 2008-08-16 17:39:05
UTC (rev 111)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/lazy/proxy/SetProxy.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -19,7 +19,7 @@
*
* Red Hat Author(s): Adam Warski
*/
-package org.jboss.envers.reader.lazy.proxy;
+package org.jboss.envers.entities.mapper.relation.lazy.proxy;
import java.util.Set;
Modified: trunk/src/main/org/jboss/envers/query/impl/AbstractVersionsQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/AbstractVersionsQuery.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/query/impl/AbstractVersionsQuery.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -22,7 +22,7 @@
package org.jboss.envers.query.impl;
import org.jboss.envers.reader.VersionsReaderImplementor;
-import org.jboss.envers.entity.EntityInstantiator;
+import org.jboss.envers.entities.EntityInstantiator;
import org.jboss.envers.query.criteria.VersionsCriterion;
import org.jboss.envers.query.VersionsQuery;
import org.jboss.envers.query.projection.VersionsProjection;
Modified: trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -36,7 +36,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class EntitiesAtRevisionQuery extends AbstractVersionsQuery {
- private Number revision;
+ private final Number revision;
public EntitiesAtRevisionQuery(VersionsConfiguration verCfg, Session session,
VersionsReaderImplementor versionsReader,
Class<?> cls,
Modified: trunk/src/main/org/jboss/envers/query/order/RevisionVersionsOrder.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/order/RevisionVersionsOrder.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/query/order/RevisionVersionsOrder.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -28,7 +28,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionVersionsOrder implements VersionsOrder {
- private boolean asc;
+ private final boolean asc;
public RevisionVersionsOrder(boolean asc) {
this.asc = asc;
Modified:
trunk/src/main/org/jboss/envers/query/projection/DistinctVersionsProjection.java
===================================================================
---
trunk/src/main/org/jboss/envers/query/projection/DistinctVersionsProjection.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/query/projection/DistinctVersionsProjection.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -29,7 +29,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class DistinctVersionsProjection implements VersionsProjection {
- private VersionsProjection projection;
+ private final VersionsProjection projection;
public DistinctVersionsProjection(VersionsProjection projection) {
this.projection = projection;
Modified: trunk/src/main/org/jboss/envers/query/projection/ProjectionWrapper.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/projection/ProjectionWrapper.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/query/projection/ProjectionWrapper.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -29,7 +29,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class ProjectionWrapper implements VersionsProjection {
- private Projection wrapped;
+ private final Projection wrapped;
public ProjectionWrapper(Projection wrapped) {
this.wrapped = wrapped;
Modified:
trunk/src/main/org/jboss/envers/query/projection/RevisionVersionsProjection.java
===================================================================
---
trunk/src/main/org/jboss/envers/query/projection/RevisionVersionsProjection.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/query/projection/RevisionVersionsProjection.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -36,7 +36,7 @@
COUNT_DISTINCT
}
- private ProjectionType type;
+ private final ProjectionType type;
public RevisionVersionsProjection(ProjectionType type) {
this.type = type;
Modified: trunk/src/main/org/jboss/envers/query/projection/VersionsProjectionList.java
===================================================================
---
trunk/src/main/org/jboss/envers/query/projection/VersionsProjectionList.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/query/projection/VersionsProjectionList.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -33,7 +33,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsProjectionList implements VersionsProjection {
- private List<VersionsProjection> projections;
+ private final List<VersionsProjection> projections;
public VersionsProjectionList() {
projections = new ArrayList<VersionsProjection>();
Modified: trunk/src/main/org/jboss/envers/revisioninfo/CustomRevisionInfoGenerator.java
===================================================================
---
trunk/src/main/org/jboss/envers/revisioninfo/CustomRevisionInfoGenerator.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/revisioninfo/CustomRevisionInfoGenerator.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -30,9 +30,9 @@
* @author Adam Warski (adam at warski dot org)
*/
public class CustomRevisionInfoGenerator implements RevisionInfoGenerator {
- private RevisionListener listener;
- private Setter revisionTimestampSetter;
- private Class<?> entityClass;
+ private final RevisionListener listener;
+ private final Setter revisionTimestampSetter;
+ private final Class<?> entityClass;
public CustomRevisionInfoGenerator(Class<?> entityClass,
Class<? extends RevisionListener>
listenerClass,
@@ -50,6 +50,9 @@
} catch (IllegalAccessException e) {
throw new MappingException(e);
}
+ } else {
+ // Default listener - none
+ listener = null;
}
}
Modified: trunk/src/main/org/jboss/envers/revisioninfo/DefaultRevisionInfoGenerator.java
===================================================================
---
trunk/src/main/org/jboss/envers/revisioninfo/DefaultRevisionInfoGenerator.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/revisioninfo/DefaultRevisionInfoGenerator.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -28,7 +28,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class DefaultRevisionInfoGenerator implements RevisionInfoGenerator {
- private String revisionInfoTimestampName;
+ private final String revisionInfoTimestampName;
public DefaultRevisionInfoGenerator(String revisionInfoTimestampName) {
this.revisionInfoTimestampName = revisionInfoTimestampName;
Modified:
trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java
===================================================================
---
trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -34,11 +34,12 @@
* @author Adam Warski (adam at warski dot org)
*/
public abstract class AbstractVersionsWorkUnit implements VersionsWorkUnit {
- protected VersionsConfiguration verCfg;
- protected Serializable id;
+ protected final VersionsConfiguration verCfg;
+ protected final Serializable id;
+ private final String entityName;
+
private Object performedData;
- private String entityName;
protected AbstractVersionsWorkUnit(String entityName, VersionsConfiguration verCfg,
Serializable id) {
this.verCfg = verCfg;
Modified: trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -34,8 +34,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class AddWorkUnit extends AbstractVersionsWorkUnit implements VersionsWorkUnit {
- private Object[] state;
- private String[] propertyNames;
+ private final Object[] state;
+ private final String[] propertyNames;
public AddWorkUnit(String entityName, VersionsConfiguration verCfg, Serializable id,
EntityPersister entityPersister, Object[] state) {
Modified:
trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java
===================================================================
---
trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-08-16
17:42:15 UTC (rev 112)
+++
trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -33,7 +33,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public class CollectionChangeWorkUnit extends AbstractVersionsWorkUnit implements
VersionsWorkUnit {
- private Object entity;
+ private final Object entity;
public CollectionChangeWorkUnit(String entityName, VersionsConfiguration verCfg,
Serializable id, Object entity) {
super(entityName, verCfg, id);
Modified: trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -34,8 +34,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class ModWorkUnit extends AbstractVersionsWorkUnit implements VersionsWorkUnit {
- private Map<String, Object> data;
- private boolean changes;
+ private final Map<String, Object> data;
+ private final boolean changes;
public ModWorkUnit(String entityName, VersionsConfiguration verCfg, Serializable id,
EntityPersister entityPersister, Object[] newState, Object[]
oldState) {
Modified: trunk/src/main/org/jboss/envers/tools/graph/Vertex.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/graph/Vertex.java 2008-08-16 17:42:15 UTC (rev
112)
+++ trunk/src/main/org/jboss/envers/tools/graph/Vertex.java 2008-08-17 14:24:36 UTC (rev
113)
@@ -29,8 +29,9 @@
* @author Adam Warski (adam at warski dot org)
*/
public class Vertex<R> {
- private R representation;
- private List<Vertex<R>> neighbours;
+ private final R representation;
+ private final List<Vertex<R>> neighbours;
+
private int startTime;
private int endTime;
Modified: trunk/src/main/org/jboss/envers/tools/log/YLog.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/log/YLog.java 2008-08-16 17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/tools/log/YLog.java 2008-08-17 14:24:36 UTC (rev 113)
@@ -31,10 +31,10 @@
* @author Adam Warski (adam at warski dot org)
*/
public class YLog {
- private Object delegate;
- private Method errorMethod;
- private Method warnMethod;
- private Method infoMethod;
+ private final Object delegate;
+ private final Method errorMethod;
+ private final Method warnMethod;
+ private final Method infoMethod;
public YLog(Object delegate, Class<?> argClass) {
this.delegate = delegate;
Modified: trunk/src/main/org/jboss/envers/tools/log/YLogManager.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/log/YLogManager.java 2008-08-16 17:42:15 UTC
(rev 112)
+++ trunk/src/main/org/jboss/envers/tools/log/YLogManager.java 2008-08-17 14:24:36 UTC
(rev 113)
@@ -37,10 +37,6 @@
private Class argClass;
private YLogManager() {
- initMethod();
- }
-
- private void initMethod() {
ClassLoader cl = YLogManager.class.getClassLoader();
try {
Modified: trunk/src/main/org/jboss/envers/tools/reflection/YClass.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/reflection/YClass.java 2008-08-16 17:42:15 UTC
(rev 112)
+++ trunk/src/main/org/jboss/envers/tools/reflection/YClass.java 2008-08-17 14:24:36 UTC
(rev 113)
@@ -32,8 +32,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class YClass {
- private YMethodsAndClasses ymc;
- private Object delegate;
+ private final YMethodsAndClasses ymc;
+ private final Object delegate;
public YClass(YMethodsAndClasses ymc, Object delegate) {
this.ymc = ymc;
Modified: trunk/src/main/org/jboss/envers/tools/reflection/YMethodsAndClasses.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/reflection/YMethodsAndClasses.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/tools/reflection/YMethodsAndClasses.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -29,46 +29,23 @@
* @author Adam Warski (adam at warski dot org)
*/
public class YMethodsAndClasses {
- private Method reflectionManager_classForNameMethod;
- private Method reflectionManager_equalsMethod;
+ private final Method reflectionManager_classForNameMethod;
+ private final Method reflectionManager_equalsMethod;
- private Method xClass_getNameMethod;
- private Method xClass_getSuperclassMethod;
- private Method xClass_getDeclaredPropertiesMethod;
- private Method xClass_getAnnotationMethod;
+ private final Method xClass_getNameMethod;
+ private final Method xClass_getSuperclassMethod;
+ private final Method xClass_getDeclaredPropertiesMethod;
+ private final Method xClass_getAnnotationMethod;
- private Method xProperty_getNameMethod;
- private Method xProperty_getAnnotationMethod;
- private Method xProperty_getTypeMethod;
+ private final Method xProperty_getNameMethod;
+ private final Method xProperty_getAnnotationMethod;
+ private final Method xProperty_getTypeMethod;
- private Class reflectionManagerClass;
- private Class xClassClass;
- private Class xPropertyClass;
-
public YMethodsAndClasses(Class<?> delegateClass) throws Exception {
- initClasses(delegateClass);
- initMethods();
- }
-
- private void initMethods() throws Exception {
- reflectionManager_classForNameMethod =
reflectionManagerClass.getMethod("classForName", String.class, Class.class);
- reflectionManager_equalsMethod =
reflectionManagerClass.getMethod("equals", xClassClass, Class.class);
-
- xClass_getNameMethod = xClassClass.getMethod("getName");
- xClass_getSuperclassMethod = xClassClass.getMethod("getSuperclass");
- xClass_getDeclaredPropertiesMethod =
xClassClass.getMethod("getDeclaredProperties", String.class);
- xClass_getAnnotationMethod = xClassClass.getMethod("getAnnotation",
Class.class);
-
- xProperty_getNameMethod = xPropertyClass.getMethod("getName");
- xProperty_getTypeMethod = xPropertyClass.getMethod("getType");
- xProperty_getAnnotationMethod =
xPropertyClass.getMethod("getAnnotation", Class.class);
- }
-
- private void initClasses(Class<?> delegateClass) {
+ // Initializing classes
ClassLoader cl = YMethodsAndClasses.class.getClassLoader();
- reflectionManagerClass = delegateClass;
-
+ Class xClassClass;
try {
xClassClass =
cl.loadClass("org.hibernate.annotations.common.reflection.XClass");
} catch (ClassNotFoundException e) {
@@ -79,6 +56,7 @@
}
}
+ Class xPropertyClass;
try {
xPropertyClass =
cl.loadClass("org.hibernate.annotations.common.reflection.XProperty");
} catch (ClassNotFoundException e) {
@@ -88,6 +66,19 @@
throw new VersionsException("No XProperty found.");
}
}
+
+ // Initializing methods
+ reflectionManager_classForNameMethod =
delegateClass.getMethod("classForName", String.class, Class.class);
+ reflectionManager_equalsMethod = delegateClass.getMethod("equals",
xClassClass, Class.class);
+
+ xClass_getNameMethod = xClassClass.getMethod("getName");
+ xClass_getSuperclassMethod = xClassClass.getMethod("getSuperclass");
+ xClass_getDeclaredPropertiesMethod =
xClassClass.getMethod("getDeclaredProperties", String.class);
+ xClass_getAnnotationMethod = xClassClass.getMethod("getAnnotation",
Class.class);
+
+ xProperty_getNameMethod = xPropertyClass.getMethod("getName");
+ xProperty_getTypeMethod = xPropertyClass.getMethod("getType");
+ xProperty_getAnnotationMethod =
xPropertyClass.getMethod("getAnnotation", Class.class);
}
public Method getXClass_getNameMethod() {
Modified: trunk/src/main/org/jboss/envers/tools/reflection/YProperty.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/reflection/YProperty.java 2008-08-16 17:42:15
UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/tools/reflection/YProperty.java 2008-08-17 14:24:36
UTC (rev 113)
@@ -30,8 +30,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class YProperty {
- private YMethodsAndClasses ymc;
- private Object delegate;
+ private final YMethodsAndClasses ymc;
+ private final Object delegate;
public YProperty(YMethodsAndClasses ymc, Object delegate) {
this.ymc = ymc;
Modified: trunk/src/main/org/jboss/envers/tools/reflection/YReflectionManager.java
===================================================================
--- trunk/src/main/org/jboss/envers/tools/reflection/YReflectionManager.java 2008-08-16
17:42:15 UTC (rev 112)
+++ trunk/src/main/org/jboss/envers/tools/reflection/YReflectionManager.java 2008-08-17
14:24:36 UTC (rev 113)
@@ -32,8 +32,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class YReflectionManager {
- private Object delegate;
- private YMethodsAndClasses ymc;
+ private final Object delegate;
+ private final YMethodsAndClasses ymc;
public YReflectionManager(Configuration cfg) throws Exception {
delegate =
cfg.getClass().getMethod("getReflectionManager").invoke(cfg);