KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > myoodb > core > storage > ObjectContainer


1 ///////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
4
//
5
// All Rights Reserved
6
//
7
// This program is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License and GNU Library
9
// General Public License as published by the Free Software Foundation;
10
// either version 2, or (at your option) any later version.
11
//
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License and GNU Library General Public License
16
// for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// and GNU Library General Public License along with this program; if
20
// not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21
// MA 02139, USA.
22
//
23
///////////////////////////////////////////////////////////////////////////////
24
package org.myoodb.core.storage;
25
26 import org.myoodb.core.*;
27 import org.myoodb.exception.*;
28
29 public class ObjectContainer extends AbstractObjectContainer
30 {
31     public ObjectContainer()
32     {
33     }
34
35     public ObjectContainer(Identifier objectId)
36     {
37         super(STATE_CREATED, objectId);
38     }
39
40     public void setDeactivationFlag(boolean flag) throws Exception JavaDoc
41     {
42         super.setDeactivationFlag(flag);
43
44         Cluster cluster = (Cluster) m_cluster; // TODO: check for null?
45

46         // save change
47
cluster.write();
48
49         if (getDeactivationFlag() == true)
50         {
51             if (getLock().getLockLevel(null) >= Lock.ACCESS_WRITE)
52             {
53                 throw new PermissionException("Invalid deactivation (object is being modified): " + getTarget());
54             }
55
56             ObjectStore objectStore = (ObjectStore) MyOodbManager.getTheManager().getStoreManager();
57             objectStore.m_clusterStore.unloadCluster(cluster.getObjectId());
58         }
59         else
60         {
61             // XXX: no need to do a loadCluster, it will be invoked on next access
62
}
63     }
64 }
65
Popular Tags