| <!DOCTYPE html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <!-- No caching headers --> |
| <meta http-equiv="cache-control" content="no-cache"/> |
| <meta http-equiv="pragma" content="no-cache"/> |
| <meta http-equiv="expires" content="-1"/> |
| <meta name="keywords" content="JDO, Apache, Java, Data, Objects"/> |
| <meta name="description" content="Apache JDO - Java Data Objects"/> |
| |
| <title>JDO Bytecode Enhancement</title> |
| |
| <link rel="icon" type="image/png" href="https://apache.github.io/db-jdo-site/images/JDO_32x32.png"/> |
| |
| <!-- |
| Apache JDO Documentation Template |
| ================================== |
| This template derived various aspects from Apache Deltaspike template, the Apache ISIS template and the Datanucleus template. |
| This template uses |
| * Bootstrap v3.3.7 (https://getbootstrap.com/) for navbar. |
| * Asciidoctor "foundation" CSS |
| * Bootswatch "cosmo" theme for Bootstrap (https://bootswatch.com/cosmo). |
| * Bootstrap TOC plugin v0.4.1 (https://afeld.github.io/bootstrap-toc/) for the table of contents. |
| * jQuery (necessary for Bootstrap's JavaScript plugins) |
| * Font-Awesome for some icons used by Asciidoctor |
| NOTE: tried using Font-Awesome CSS hosted locally but then fails to work! |
| --> |
| <link href="css/bootswatch/3.3.7/bootstrap-cosmo.css" rel="stylesheet"/> |
| <link href="css/bootstrap-toc/0.4.1/bootstrap-toc.min.css" rel="stylesheet"/> |
| |
| <link href="css/asciidoctor/foundation.css" rel="stylesheet"/> |
| <link href="css/datanucleus_theme.css" rel="stylesheet"/> |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> |
| <script src="js/bootstrap/3.3.7/bootstrap.min.js"></script> |
| <script src="js/bootstrap-toc/0.4.1/bootstrap-toc.min.js"></script> |
| |
| <!-- Coderay syntax formatter --> |
| <style type="text/css"> |
| /* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */ |
| /*pre.CodeRay {background-color:#f7f7f8;}*/ |
| .CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em} |
| .CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)} |
| .CodeRay .line-numbers strong{color:rgba(0,0,0,.4)} |
| table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none} |
| table.CodeRay td{vertical-align: top;line-height:1.45} |
| table.CodeRay td.line-numbers{text-align:right} |
| table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)} |
| table.CodeRay td.code{padding:0 0 0 .5em} |
| table.CodeRay td.code>pre{padding:0} |
| .CodeRay .debug{color:#fff !important;background:#000080 !important} |
| .CodeRay .annotation{color:#007} |
| .CodeRay .attribute-name{color:#000080} |
| .CodeRay .attribute-value{color:#700} |
| .CodeRay .binary{color:#509} |
| .CodeRay .comment{color:#998;font-style:italic} |
| .CodeRay .char{color:#04d} |
| .CodeRay .char .content{color:#04d} |
| .CodeRay .char .delimiter{color:#039} |
| .CodeRay .class{color:#458;font-weight:bold} |
| .CodeRay .complex{color:#a08} |
| .CodeRay .constant,.CodeRay .predefined-constant{color:#008080} |
| .CodeRay .color{color:#099} |
| .CodeRay .class-variable{color:#369} |
| .CodeRay .decorator{color:#b0b} |
| .CodeRay .definition{color:#099} |
| .CodeRay .delimiter{color:#000} |
| .CodeRay .doc{color:#970} |
| .CodeRay .doctype{color:#34b} |
| .CodeRay .doc-string{color:#d42} |
| .CodeRay .escape{color:#666} |
| .CodeRay .entity{color:#800} |
| .CodeRay .error{color:#808} |
| .CodeRay .exception{color:inherit} |
| .CodeRay .filename{color:#099} |
| .CodeRay .function{color:#900;font-weight:bold} |
| .CodeRay .global-variable{color:#008080} |
| .CodeRay .hex{color:#058} |
| .CodeRay .integer,.CodeRay .float{color:#099} |
| .CodeRay .include{color:#555} |
| .CodeRay .inline{color:#000} |
| .CodeRay .inline .inline{background:#ccc} |
| .CodeRay .inline .inline .inline{background:#bbb} |
| .CodeRay .inline .inline-delimiter{color:#d14} |
| .CodeRay .inline-delimiter{color:#d14} |
| .CodeRay .important{color:#555;font-weight:bold} |
| .CodeRay .interpreted{color:#b2b} |
| .CodeRay .instance-variable{color:#008080} |
| .CodeRay .label{color:#970} |
| .CodeRay .local-variable{color:#963} |
| .CodeRay .octal{color:#40e} |
| .CodeRay .predefined{color:#369} |
| .CodeRay .preprocessor{color:#579} |
| .CodeRay .pseudo-class{color:#555} |
| .CodeRay .directive{font-weight:bold} |
| .CodeRay .type{font-weight:bold} |
| .CodeRay .predefined-type{color:inherit} |
| .CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold} |
| .CodeRay .key{color:#808} |
| .CodeRay .key .delimiter{color:#606} |
| .CodeRay .key .char{color:#80f} |
| .CodeRay .value{color:#088} |
| .CodeRay .regexp .delimiter{color:#808} |
| .CodeRay .regexp .content{color:#808} |
| .CodeRay .regexp .modifier{color:#808} |
| .CodeRay .regexp .char{color:#d14} |
| .CodeRay .regexp .function{color:#404;font-weight:bold} |
| .CodeRay .string{color:#d20} |
| .CodeRay .string .string .string{background:#ffd0d0} |
| .CodeRay .string .content{color:#d14} |
| .CodeRay .string .char{color:#d14} |
| .CodeRay .string .delimiter{color:#d14} |
| .CodeRay .shell{color:#d14} |
| .CodeRay .shell .delimiter{color:#d14} |
| .CodeRay .symbol{color:#990073} |
| .CodeRay .symbol .content{color:#a60} |
| .CodeRay .symbol .delimiter{color:#630} |
| .CodeRay .tag{color:#008080} |
| .CodeRay .tag-special{color:#d70} |
| .CodeRay .variable{color:#036} |
| .CodeRay .insert{background:#afa} |
| .CodeRay .delete{background:#faa} |
| .CodeRay .change{color:#aaf;background:#007} |
| .CodeRay .head{color:#f8f;background:#505} |
| .CodeRay .insert .insert{color:#080} |
| .CodeRay .delete .delete{color:#800} |
| .CodeRay .change .change{color:#66f} |
| .CodeRay .head .head{color:#f4f} |
| </style> |
| </head> |
| <body data-spy="scroll" data-target="#toc"> |
| <!-- Navbar --> |
| <nav class="navbar navbar-default navbar-static-top"> |
| <div class="container"> |
| <div class="navbar-header"> |
| <!-- Three line menu button for use on mobile screens --> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <!-- 'style' added to align image with navbar. FIX THIS --> |
| <a class="navbar-brand" href="https://db.apache.org/jdo/"> |
| <img style="margin-top: -12px;" alt="Brand" src="images/JDO_44x44.png"/> |
| </a> |
| <!-- TODO Any way to abstract the version from Maven? --> |
| <a class="navbar-brand" href="index.html">Apache JDO</a> |
| </div> |
| <!-- Navbar that will collapse on mobile screens --> |
| <div id="navbar" class="navbar-collapse collapse"> |
| <ul class="nav navbar-nav"> |
| <li class="dropdown"> |
| |
| <!-- menu item General --> |
| |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">General<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="why_jdo.html">Why JDO?</a></li> |
| <li><a href="getting-started.html">Getting Started</a></li> |
| <li><a href="specifications.html">Specifications</a></li> |
| <li><a href="tck.html">TCK</a></li> |
| <li><a href="javadoc.html">API Javadoc</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="jdo_v_jpa.html">JDO v JPA</a></li> |
| <li><a href="jdo_v_jpa_api.html">JDO v JPA : API</a></li> |
| <li><a href="jdo_v_jpa_orm.html">JDO v JPA : ORM</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="license.html">License</a></li> |
| <li><a href="impls.html">Implementations</a></li> |
| <li><a href="jdo_3_0_overview.html">JDO 3.0 Overview</a></li> |
| <li><a href="references.html">References</a></li> |
| <li><a href="glossary.html">Glossary</a></li> |
| </ul> |
| </li> |
| |
| <!-- menu item API Usage --> |
| |
| <li class="dropdown"> |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">API Usage<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="jdohelper.html">JDO Helper</a></li> |
| <li><a href="pmf.html">PersistenceManagerFactory</a></li> |
| <li><a href="pm.html">PersistenceManager</a></li> |
| <li><a href="transactions.html">Transactions</a></li> |
| <li><a href="attach_detach.html">Attach-Detach</a></li> |
| <li><a href="fetchgroups.html">Fetch Groups</a></li> |
| <li><a href="state_transition.html">Object States</a></li> |
| <li><a href="object_retrieval.html">Object Retrieval</a></li> |
| <li><a href="exceptions.html">Exceptions</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="guides-replication.html">Data Replication</a></li> |
| </ul> |
| </li> |
| |
| <!-- menu item Types & Metadata --> |
| |
| <li class="dropdown"> |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" style="background-color:#2385c6">Types & Metadata<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="class_types.html">Types of Classes</a></li> |
| <li><a href="field_types.html">Types of Fields</a></li> |
| <li role="separator" class="divider"></li> |
| <!-- <li class="dropdown-header">Metadata</li> --> |
| <li><a href="metadata.html">MetaData</a></li> |
| <li><a href="annotations.html">Annotations</a></li> |
| <li><a href="jdo_dtd.html">jdo DTD/XSD</a></li> |
| <li><a href="orm_dtd.html">orm DTD/XSD</a></li> |
| <li><a href="jdoquery_dtd.html">jdoquery DTD/XSD</a></li> |
| <li><a href="jdoconfig_dtd.html">jdoconfig DTD/XSD</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="enhancement.html">Bytecode Enhancement</a></li> |
| </ul> |
| </li> |
| |
| <!-- menu item Query --> |
| |
| <li class="dropdown"> |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Query<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="jdoql.html">JDOQL</a></li> |
| <li><a href="jdoql_result.html">Result</a></li> |
| <li><a href="jdoql_methods.html">Methods</a></li> |
| <li><a href="jdoql_quickref.pdf">Quick Ref PDF</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="extents.html">Extents</a></li> |
| </ul> |
| </li> |
| |
| <!-- menu item Community --> |
| |
| <li class="dropdown"> |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Community<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="get-involved.html">Get Involved</a></li> |
| <li><a href="team-list.html">Project Team</a></li> |
| <li><a href="mail-lists.html">Mailing Lists</a></li> |
| <li><a href="faq.html">FAQ</a></li> |
| </ul> |
| </li> |
| |
| <!-- menu item Development --> |
| |
| <li class="dropdown"> |
| |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Development<span class="caret"></span></a> |
| |
| <ul class="dropdown-menu"> |
| <li><a href="roadmap.html">RoadMap / TODO</a></li> |
| <li><a href="downloads.html">Downloads</a></li> |
| <li><a href="source-code.html">Source Code</a></li> |
| <li><a href="coding-standards.html">Coding Standards</a></li> |
| <li><a href="issuetracking.html">Issue Tracking</a></li> |
| </ul> |
| </li> |
| </ul> |
| <!-- 'style' added to fix height of input box. FIX THIS --> |
| <form class="navbar-form navbar-left" role="search" id="search-form" action="https://www.google.com/search" method="get" style="padding: 1px 15px;"> |
| <div class="form-group"> |
| <input name="sitesearch" value="db.apache.org/jdo" type="hidden"> |
| <input name="q" type="text" class="form-control" placeholder="Search" style="margin-top: 7px; padding: 1px; border-radius: 5px; height: 30px; vertical-align: middle;"> |
| </div> |
| </form> |
| </div> |
| </div> |
| </nav> |
| <div class="container"> |
| |
| <!-- No TOC --> |
| <div class="row-fluid"> |
| <div class="col-sm-12"> |
| |
| <!-- no heading --> |
| |
| <div id="doc-content"> |
| <div class="sect1"> |
| <h2 id="index">JDO Bytecode Enhancement<a id="JDO_Bytecode_Enhancement"></a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>JDO defines a byte-code enhancement process that provides for dirty |
| detection of fields. Before a class is used at runtime it is compiled |
| and then "enhanced" to implement the interface <em>PersistenceCapable</em>, and |
| optionally also <em>Detachable</em>.</p> |
| </div> |
| <div class="paragraph"> |
| <p>We can demonstrate this by taking a sample class, and seeing it before |
| and after enhancement. We start with the following class</p> |
| </div> |
| <div class="literalblock"> |
| <div class="content"> |
| <pre>package org.apache.jdo.test; |
| |
| public class A |
| { |
| long id; |
| String name; |
| B b; |
| |
| public A(String name) |
| { |
| this.name = name; |
| } |
| |
| public void setId(long id) |
| { |
| this.id = id; |
| } |
| |
| public void setB(B b) |
| { |
| this.b = b; |
| } |
| |
| public String getName() |
| { |
| return name; |
| } |
| |
| public B getB() |
| { |
| return b; |
| } |
| |
| public long getId() |
| { |
| return id; |
| } |
| |
| public String toString() |
| { |
| return "A : id=" + id + " [" + name + "] b=\"" + b + "\""; |
| } |
| }</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>and require it to be <em>PersistenceCapable</em> and <em>Detachable</em>. The |
| enhancement process needs to intercept all updates of the fields of the |
| class (id, name, b) as well as add on the necessary |
| <em>PersistenceCapable</em>, <em>Detachable</em> methods. After "enhancement" it |
| becomes</p> |
| </div> |
| <div class="literalblock"> |
| <div class="content"> |
| <pre>package org.apache.jdo.test; |
| import java.util.BitSet; |
| |
| import javax.jdo.JDODetachedFieldAccessException; |
| import javax.jdo.JDOFatalInternalException; |
| import javax.jdo.PersistenceManager; |
| import javax.jdo.identity.LongIdentity; |
| import javax.jdo.spi.Detachable; |
| import javax.jdo.spi.JDOImplHelper; |
| import javax.jdo.spi.JDOPermission; |
| import javax.jdo.spi.PersistenceCapable; |
| import javax.jdo.spi.StateManager; |
| |
| public class A implements PersistenceCapable, Detachable |
| { |
| long id; |
| String name; |
| B b; |
| protected transient StateManager jdoStateManager; |
| protected transient byte jdoFlags; |
| protected Object[] jdoDetachedState; |
| private static final byte[] jdoFieldFlags; |
| private static final Class jdoPersistenceCapableSuperclass; |
| private static final Class[] jdoFieldTypes; |
| private static final String[] jdoFieldNames = __jdoFieldNamesInit(); |
| private static final int jdoInheritedFieldCount; |
| |
| static |
| { |
| jdoFieldTypes = __jdoFieldTypesInit(); |
| jdoFieldFlags = __jdoFieldFlagsInit(); |
| jdoInheritedFieldCount = __jdoGetInheritedFieldCount(); |
| jdoPersistenceCapableSuperclass = __jdoPersistenceCapableSuperclassInit(); |
| JDOImplHelper.registerClass(___jdo$loadClass("org.apache.jdo.test.A"), |
| jdoFieldNames, jdoFieldTypes, |
| jdoFieldFlags, |
| jdoPersistenceCapableSuperclass, new A()); |
| } |
| |
| public void setId(long id) |
| { |
| jdoSetid(this, id); |
| } |
| |
| public void setB(B b) |
| { |
| jdoSetb(this, b); |
| } |
| |
| public String getName() |
| { |
| return jdoGetname(this); |
| } |
| |
| public B getB() |
| { |
| return jdoGetb(this); |
| } |
| |
| public long getId() |
| { |
| return jdoGetid(this); |
| } |
| |
| public String toString() |
| { |
| return new StringBuilder().append("A : id=").append(jdoGetid(this)) |
| .append(" [").append(jdoGetname(this)) |
| .append("] b=\"").append(jdoGetb(this)) |
| .append("\"").toString(); |
| } |
| |
| public void jdoCopyKeyFieldsFromObjectId(PersistenceCapable.ObjectIdFieldConsumer fc, Object oid) |
| { |
| if (fc == null) |
| throw new IllegalArgumentException |
| ("ObjectIdFieldConsumer is null"); |
| if (!(oid instanceof LongIdentity)) |
| throw new ClassCastException |
| ("oid is not instanceof javax.jdo.identity.LongIdentity"); |
| LongIdentity o = (LongIdentity) oid; |
| fc.storeLongField(1, o.getKey()); |
| } |
| |
| protected void jdoCopyKeyFieldsFromObjectId(Object oid) |
| { |
| if (!(oid instanceof LongIdentity)) |
| throw new ClassCastException |
| ("key class is not javax.jdo.identity.LongIdentity or null"); |
| LongIdentity o = (LongIdentity) oid; |
| id = o.getKey(); |
| } |
| |
| public final void jdoCopyKeyFieldsToObjectId(Object oid) |
| { |
| throw new JDOFatalInternalException |
| ("It's illegal to call jdoCopyKeyFieldsToObjectId for a class with Single Field Identity."); |
| } |
| |
| public final void jdoCopyKeyFieldsToObjectId |
| (PersistenceCapable.ObjectIdFieldSupplier fs, Object oid) { |
| throw new JDOFatalInternalException |
| ("It's illegal to call jdoCopyKeyFieldsToObjectId for a class with Single Field Identity."); |
| } |
| |
| public final Object jdoGetObjectId() |
| { |
| if (jdoStateManager != null) |
| return jdoStateManager.getObjectId(this); |
| if (this.jdoIsDetached() != true) |
| return null; |
| return jdoDetachedState[0]; |
| } |
| |
| public final Object jdoGetVersion() |
| { |
| if (jdoStateManager != null) |
| return jdoStateManager.getVersion(this); |
| if (this.jdoIsDetached() != true) |
| return null; |
| return jdoDetachedState[1]; |
| } |
| |
| protected final void jdoPreSerialize() |
| { |
| if (jdoStateManager != null) |
| jdoStateManager.preSerialize(this); |
| } |
| |
| public final PersistenceManager jdoGetPersistenceManager() |
| { |
| return (jdoStateManager != null |
| ? jdoStateManager.getPersistenceManager(this) : null); |
| } |
| |
| public final Object jdoGetTransactionalObjectId() |
| { |
| return (jdoStateManager != null |
| ? jdoStateManager.getTransactionalObjectId(this) : null); |
| } |
| |
| public final boolean jdoIsDeleted() |
| { |
| return (jdoStateManager != null ? jdoStateManager.isDeleted(this): false); |
| } |
| |
| public final boolean jdoIsDirty() |
| { |
| if (jdoStateManager != null) |
| return jdoStateManager.isDirty(this); |
| if (this.jdoIsDetached() != true) |
| return false; |
| if (((BitSet) jdoDetachedState[3]).length() <= 0) |
| return false; |
| return true; |
| } |
| |
| public final boolean jdoIsNew() |
| { |
| return jdoStateManager != null ? jdoStateManager.isNew(this) : false; |
| } |
| |
| public final boolean jdoIsPersistent() |
| { |
| return (jdoStateManager != null ? jdoStateManager.isPersistent(this): false); |
| } |
| |
| public final boolean jdoIsTransactional() |
| { |
| return (jdoStateManager != null ? jdoStateManager.isTransactional(this): false); |
| } |
| |
| public final boolean jdoIsDetached() |
| { |
| if (jdoStateManager == null) { |
| if (jdoDetachedState == null) |
| return false; |
| return true; |
| } |
| return false; |
| } |
| |
| public final void jdoMakeDirty(String fieldName) |
| { |
| if (jdoStateManager != null) |
| jdoStateManager.makeDirty(this, fieldName); |
| } |
| |
| public final Object jdoNewObjectIdInstance() |
| { |
| return new LongIdentity(getClass(), id); |
| } |
| |
| public final Object jdoNewObjectIdInstance(Object key) |
| { |
| if (key == null) |
| throw new IllegalArgumentException("key is null"); |
| if (key instanceof String != true) |
| return new LongIdentity(this.getClass(), (Long) key); |
| return new LongIdentity(this.getClass(), (String) key); |
| } |
| |
| public final void jdoProvideFields(int[] fieldId) |
| { |
| if (fieldId == null) |
| throw new IllegalArgumentException("argment is null"); |
| int i = fieldId.length - 1; |
| if (i >= 0) |
| { |
| do |
| jdoProvideField(fieldId[i]); |
| while (--i >= 0); |
| } |
| } |
| |
| public final void jdoReplaceFields(int[] fieldId) |
| { |
| if (fieldId == null) |
| throw new IllegalArgumentException("argument is null"); |
| int i = fieldId.length; |
| if (i > 0) |
| { |
| int i_0_ = 0; |
| do |
| jdoReplaceField(fieldId[i_0_]); |
| while (++i_0_ < i); |
| } |
| } |
| |
| public final void jdoReplaceFlags() |
| { |
| if (jdoStateManager != null) |
| { |
| A a = this; |
| a.jdoFlags = a.jdoStateManager.replacingFlags(this); |
| } |
| } |
| |
| public final synchronized void jdoReplaceStateManager(StateManager stateManager) |
| { |
| if (jdoStateManager != null) |
| { |
| A a = this; |
| a.jdoStateManager = a.jdoStateManager.replacingStateManager(this, stateManager); |
| } |
| else |
| { |
| JDOImplHelper.checkAuthorizedStateManager(sm); |
| jdoStateManager = stateManager; |
| jdoFlags = (byte) 1; |
| } |
| } |
| |
| public final synchronized void jdoReplaceDetachedState() |
| { |
| if (jdoStateManager == null) |
| throw new IllegalStateException("state manager is null"); |
| A a = this; |
| a.jdoDetachedState = a.jdoStateManager.replacingDetachedState(this, jdoDetachedState); |
| } |
| |
| public PersistenceCapable jdoNewInstance(StateManager sm) |
| { |
| A result = new A(); |
| A a = result; |
| a.jdoFlags = (byte) 1; |
| a.jdoStateManager = sm; |
| return a; |
| } |
| |
| public PersistenceCapable jdoNewInstance(StateManager sm, Object o) |
| { |
| A result = new A(); |
| A a = result; |
| a.jdoFlags = (byte) 1; |
| a.jdoStateManager = sm; |
| result.jdoCopyKeyFieldsFromObjectId(o); |
| return a; |
| } |
| |
| public void jdoReplaceField(int fieldIndex) |
| { |
| if (jdoStateManager == null) |
| throw new IllegalStateException("state manager is null"); |
| switch (fieldIndex) |
| { |
| case 0: |
| { |
| A a = this; |
| a.b = (B) a.jdoStateManager.replacingObjectField(this, fieldIndex); |
| break; |
| } |
| case 1: |
| { |
| A a = this; |
| a.id = a.jdoStateManager.replacingLongField(this, fieldIndex); |
| break; |
| } |
| case 2: |
| { |
| A a = this; |
| a.name = a.jdoStateManager.replacingStringField(this, fieldIndex); |
| break; |
| } |
| default: |
| throw new IllegalArgumentException("out of field index :" + fieldIndex); |
| } |
| } |
| |
| public void jdoProvideField(int fieldIndex) |
| { |
| if (jdoStateManager == null) |
| throw new IllegalStateException("state manager is null"); |
| switch (fieldIndex) |
| { |
| case 0: |
| jdoStateManager.providedObjectField(this, fieldIndex, b); |
| break; |
| case 1: |
| jdoStateManager.providedLongField(this, fieldIndex, id); |
| break; |
| case 2: |
| jdoStateManager.providedStringField(this, fieldIndex, name); |
| break; |
| default: |
| throw new IllegalArgumentException("out of field index :" + fieldIndex); |
| } |
| } |
| |
| protected final void jdoCopyField(A obj, int index) |
| { |
| switch (index) |
| { |
| case 0: |
| b = obj.b; |
| break; |
| case 1: |
| id = obj.id; |
| break; |
| case 2: |
| name = obj.name; |
| break; |
| default: |
| throw new IllegalArgumentException("out of field index :" + index); |
| } |
| } |
| |
| public void jdoCopyFields(Object obj, int[] fieldNumbers) |
| { |
| if (jdoStateManager == null) |
| throw new IllegalStateException("state manager is null"); |
| if (fieldNumbers == null) |
| throw new IllegalStateException("fieldNumbers is null"); |
| if (obj instanceof A != true) |
| throw new IllegalArgumentException("object is not org.apache.jdo.test.A"); |
| A me = (A) obj; |
| if (jdoStateManager != me.jdoStateManager) |
| throw new IllegalArgumentException("state manager unmatch"); |
| int i = fieldNumbers.length - 1; |
| if (i >= 0) |
| { |
| do |
| jdoCopyField(me, fieldNumbers[i]); |
| while (--i >= 0); |
| } |
| } |
| |
| private static final String[] __jdoFieldNamesInit() |
| { |
| return new String[] { "b", "id", "name" }; |
| } |
| |
| private static final Class[] __jdoFieldTypesInit() |
| { |
| return new Class[] { ___jdo$loadClass("org.apache.jdo.test.B"), Long.TYPE, |
| ___jdo$loadClass("java.lang.String") }; |
| } |
| |
| private static final byte[] __jdoFieldFlagsInit() |
| { |
| return new byte[] { 10, 24, 21 }; |
| } |
| |
| protected static int __jdoGetInheritedFieldCount() |
| { |
| return 0; |
| } |
| |
| protected static int jdoGetManagedFieldCount() |
| { |
| return 3; |
| } |
| |
| private static Class __jdoPersistenceCapableSuperclassInit() |
| { |
| return null; |
| } |
| |
| public static Class ___jdo$loadClass(String className) |
| { |
| try |
| { |
| return Class.forName(className); |
| } |
| catch (ClassNotFoundException e) |
| { |
| throw new NoClassDefFoundError(e.getMessage()); |
| } |
| } |
| |
| private Object jdoSuperClone() |
| throws CloneNotSupportedException |
| { |
| A o = (A) super.clone(); |
| o.jdoFlags = (byte) 0; |
| o.jdoStateManager = null; |
| return o; |
| } |
| |
| public A() |
| { |
| /* empty */ |
| } |
| |
| static void jdoSetb(A objPC, B b_m) |
| { |
| if (objPC.jdoStateManager == null) |
| objPC.b = b_m; |
| else |
| objPC.jdoStateManager.setObjectField(objPC, 0, objPC.b, b_m); |
| if (objPC.jdoIsDetached() == true) |
| ((BitSet) objPC.jdoDetachedState[3]).set(0); |
| } |
| |
| static B jdoGetb(A objPC) |
| { |
| if (objPC.jdoStateManager != null |
| && !objPC.jdoStateManager.isLoaded(objPC, 0)) |
| return (B) objPC.jdoStateManager.getObjectField(objPC, 0, objPC.b); |
| if (objPC.jdoIsDetached() != false |
| && ((BitSet) objPC.jdoDetachedState[2]).get(0) != true |
| && ((BitSet) objPC.jdoDetachedState[3]).get(0) != true) |
| throw new JDODetachedFieldAccessException |
| ("You have just attempted to access field \"b\" yet this field was not detached when you detached the object. " + |
| "Either dont access this field, or detach the field when detaching the object."); |
| return objPC.b; |
| } |
| |
| static void jdoSetid(A objPC, long id_n) |
| { |
| objPC.id = id_n; |
| } |
| |
| static long jdoGetid(A objPC) |
| { |
| return objPC.id; |
| } |
| |
| static void jdoSetname(A objPC, String name_c) |
| { |
| if (objPC.jdoFlags != 0 && objPC.jdoStateManager != null) |
| objPC.jdoStateManager.setStringField(objPC, 2, objPC.name, name_c); |
| else |
| { |
| objPC.name = name_c; |
| if (objPC.jdoIsDetached() == true) |
| ((BitSet) objPC.jdoDetachedState[3]).set(2); |
| } |
| } |
| |
| static String jdoGetname(A objPC) |
| { |
| if (objPC.jdoFlags > 0 && objPC.jdoStateManager != null && !objPC.jdoStateManager.isLoaded(objPC, 2)) |
| return objPC.jdoStateManager.getStringField(objPC, 2, objPC.name); |
| if (objPC.jdoIsDetached() != false && ((BitSet) objPC.jdoDetachedState[2]).get(2) != true) |
| throw new JDODetachedFieldAccessException |
| ("You have just attempted to access field \"name\" yet this field was not detached when you detached the object." + |
| "Either dont access this field, or detach the field when detaching the object."); |
| return objPC.name; |
| } |
| |
| public A(String name) |
| { |
| jdoSetname(this, name); |
| } |
| }</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| |
| <footer style="color:#fff; background-color:#222222; padding: 5px;"> |
| <div class="container"> |
| <div class="row" style="margin-top:25px"> |
| <div class="col-sm" align="center"> |
| <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> |
| | |
| <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> |
| | |
| <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> |
| | |
| <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> |
| | |
| <a href="mail-lists.html" title="Mailing Lists">Mailing Lists</a> |
| | |
| <a href="api31/apidocs/index.html" title="Latest Javadocs">Latest Javadocs</a> |
| </div> |
| </div> |
| <p class="text-center" style="margin-top:16px">© 2005-2020 Apache Software Foundation. All Rights Reserved.</p> |
| </div> |
| </footer> |
| |
| </body> |
| </html> |