Package nexj.core.persistence

Source Code of nexj.core.persistence.CounterGenerator

// Copyright 2010 NexJ Systems Inc. This software is licensed under the terms of the Eclipse Public License 1.0
package nexj.core.persistence;

import nexj.core.meta.Metaclass;
import nexj.core.runtime.Instance;

/**
* OID generator using a persistent counter.
*/
public class CounterGenerator implements OIDGenerator
{
   // constants

   /**
    * Value count for metadata validation.
    * Used by the metadata loader.
    */
   public final static int VALUE_COUNT = 1;

   // operations

   /**
    * @see nexj.core.persistence.OIDGenerator#generateOID(nexj.core.runtime.Instance, nexj.core.persistence.PersistenceAdapter)
    */
   public OID generateOID(Instance instance, PersistenceAdapter adapter)
   {
      Metaclass metaclass = instance.getMetaclass().getPersistenceRoot();

      return new OID(new Object[]{instance.getInvocationContext().getMetadata()
         .getMetaclass("SysCounter").invoke("next", new Object[]{"class." + metaclass.getName()})});
   }
}
TOP

Related Classes of nexj.core.persistence.CounterGenerator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.