/* * 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 javax.persistence.GeneratedValue; import javax.persistence.Version; import javax.persistence.Entity; import org.apache.magma.beans.MagReadOnly; /** * Provides by default a version field to those entities missing it. * * @author Simone Gianni */ public aspect InstallVersionByDefault { /** * Marker interface for beans receiving the default version field. * * @author Simone Gianni */ public static interface WithDefaultVersion { public long getVersion(); public void setVersion(long newVersion); } declare parents : ((@Entity *) && !(@NoVersion *) && !hasmethod(@Version public * get*()) && !hasfield(@Version * *)) implements WithDefaultVersion; //declare parents : ((@Entity *) && !(@NoVersion *)) implements WithDefaultVersion; /** * The default version field. */ private long WithDefaultVersion.version; /** * Getter for the default version field. * @return The version of the bean. */ @Version @MagReadOnly public long WithDefaultVersion.getVersion() { return version; } /** * Setter for the default version field. * @param newVersion The new version of the bean. */ public void WithDefaultVersion.setVersion(long newVersion) { version = newVersion; } }