📄 wizardobjectcontainer.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: WizardObjectContainer.java,v 1.20 2000/10/28 16:55:18 daniela Exp $package org.ozoneDB.core.wizardStore;import java.io.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.*;import org.ozoneDB.core.*;import org.ozoneDB.util.*;/** * The "Wizard" implementation of the ObjectContainer interface. Much of the * lock functionality is implemented in the Cluster class. * * Note: only the join/commit/abort methods are synchronized. All other methods * are guaranteed to run exclusively through the explicite locks * * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.20 $Date: 2000/10/28 16:55:18 $ */public final class WizardObjectContainer extends AbstractObjectContainer implements Externalizable { protected final static long serialVersionUID = 1L; protected final static byte subSerialVersionUID = 1; protected Cluster cluster; /** * The currently commited target object of the container. */ protected OzoneCompatible target; protected ObjectID objID; protected String name; protected transient int invokeCount; protected long modTime; /** * Constructor for object serialization via Externalizable. */ public WizardObjectContainer() { } public WizardObjectContainer( ObjectID _objID ) { state = STATE_CREATED; objID = _objID; } public long modTime() { return cluster.modTime(); } protected boolean isDeleted() { return (state() & ObjectContainer.STATE_DELETED) > 0; } protected boolean isCreated() { return (state() & ObjectContainer.STATE_CREATED) > 0; } /** * Returns the Class for the target object. This method is used by * AbstractObjectContainer. */ public Class targetClass() { return target.getClass(); } public void setTarget( OzoneCompatible _target ) { if (target != null) { target.setContainer( null ); } target = _target; target.setContainer( this ); } public OzoneCompatible target() { return target; } public void touch() { cluster.touch(); } public Lock lock() { return cluster.lock; } public void updateLockLevel( Transaction ta ) throws Exception { if (cluster.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { cluster.env.logWriter.newEntry( this, "upgradeLockLevel(): ", LogWriter.DEBUG3 ); } cluster.updateLockLevel( ta ); } public synchronized void notifyAllTAs( Transaction ta ) { cluster.lock.notifyAll(); } public Permissions permissions() { return cluster.permissions; } public int lockLevel( Transaction ta ) { return cluster.lock.level( ta ); } public boolean isInvoked() { // for performance reasons we assume that the specified transaction // is the locking transaction return invokeCount > 0; } public Object invokeTarget( Env env, String methodName, String sig, Object[] args ) throws Exception { if (cluster.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { cluster.env.logWriter.newEntry( this, "invokeTarget(): ", LogWriter.DEBUG3 ); } invokeCount++; Object result = super.invokeTarget( env, methodName, sig, args ); invokeCount--; return result; } public void deleteTarget() { if (cluster.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { cluster.env.logWriter.newEntry( this, "deleteTarget(): ", LogWriter.DEBUG3 ); } raiseState( STATE_DELETED ); } public void nameTarget( String _name ) { if (cluster.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { cluster.env.logWriter.newEntry( this, "nameTarget(): ", LogWriter.DEBUG3 ); } name = _name; } public DxCollection allLockers() { return cluster.allLockers(); } public boolean equals( Object obj ) { if (obj != null && obj instanceof WizardObjectContainer) { WizardObjectContainer rhs = (WizardObjectContainer)obj; return objID.equals( rhs.objID ); } return false; } public ObjectID id() { return objID; } public String name() { return name; } public void setName( String _name ) { name = _name; } public void writeExternal( ObjectOutput out ) throws IOException { // System.out.println ("container.writeExternal()..."); out.writeByte( subSerialVersionUID ); out.writeObject( target ); // out.writeObject (objID); out.writeLong( objID.value() ); out.writeObject( name ); out.writeByte( (byte)state ); } public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // System.out.println ("container.readExternal()..."); byte streamVersion = in.readByte(); target = (OzoneCompatible)in.readObject(); if (target != null) { target.setContainer( this ); } // objID = (ObjectID)in.readObject(); objID = new ObjectID( in.readLong() ); name = (String)in.readObject(); state = (int)in.readByte(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -