001: ///////////////////////////////////////////////////////////////////////////////
002: //
003: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
004: //
005: // All Rights Reserved
006: //
007: // This program is free software; you can redistribute it and/or modify
008: // it under the terms of the GNU General Public License and GNU Library
009: // General Public License as published by the Free Software Foundation;
010: // either version 2, or (at your option) any later version.
011: //
012: // This program is distributed in the hope that it will be useful,
013: // but WITHOUT ANY WARRANTY; without even the implied warranty of
014: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: // GNU General Public License and GNU Library General Public License
016: // for more details.
017: //
018: // You should have received a copy of the GNU General Public License
019: // and GNU Library General Public License along with this program; if
020: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
021: // MA 02139, USA.
022: //
023: ///////////////////////////////////////////////////////////////////////////////
024: package org.myoodb.core;
025:
026: import org.myoodb.*;
027:
028: abstract interface AbstractDatabaseInterface {
029: public MyOodbProxy createRoot(String rootName, Class classType);
030:
031: public MyOodbProxy createRoot(String rootName, Class[] classTypes);
032:
033: public MyOodbProxy createRoot(String rootName, String className);
034:
035: public MyOodbProxy createRoot(String rootName, Class classType,
036: Class[] sig, Object[] args);
037:
038: public MyOodbProxy createRoot(String rootName, String className,
039: Class[] sig, Object[] args);
040:
041: public MyOodbProxy createRoot(String rootName, Class classType,
042: String sig, Object[] args);
043:
044: public MyOodbProxy createRoot(String rootName, String className,
045: String sig, Object[] args);
046:
047: public MyOodbProxy createObject(Class classType);
048:
049: public MyOodbProxy createObject(Class[] classTypes);
050:
051: public MyOodbProxy createObject(String className);
052:
053: public MyOodbProxy createObject(Class classType, Class[] sig,
054: Object[] args);
055:
056: public MyOodbProxy createObject(String className, Class[] sig,
057: Object[] args);
058:
059: public MyOodbProxy createObject(Class classType, String sig,
060: Object[] args);
061:
062: public MyOodbProxy createObject(String className, String sig,
063: Object[] args);
064:
065: public void deleteObject(MyOodbRemote obj);
066:
067: public MyOodbProxy getRoot(String rootName);
068:
069: public MyOodbLocal getObject(MyOodbRemote obj);
070:
071: public MyOodbProxy getObject(org.myoodb.core.Identifier handle);
072:
073: public void setBean(org.myoodb.core.Identifier handle,
074: MyOodbBean bean);
075:
076: public MyOodbBean getBean(org.myoodb.core.Identifier handle);
077:
078: public void setXML(org.myoodb.core.Identifier handle, String xml);
079:
080: public String getXML(org.myoodb.core.Identifier handle);
081:
082: public Object invokeMethod(MyOodbRemote obj, int methodIndex,
083: Object[] args, int accessLevel, int timeout);
084:
085: public Object invokeMethod(MyOodbRemote obj, String methodName,
086: String sig, Object[] args, int accessLevel, int timeout);
087:
088: public void setCommunicationInterfacePassword(String oldPassword,
089: String newPassword);
090: }
091:
092: public abstract class AbstractDatabase implements
093: AbstractDatabaseInterface {
094: public static String createSignature(Class[] sig) {
095: if ((sig == null) || (sig.length == 0)) {
096: return null;
097: }
098:
099: StringBuilder signature = new StringBuilder(sig[0].getName());
100: for (int i = 1; i < sig.length; i++) {
101: signature.append(MethodHelper.SIGNATURE_DELIMITER);
102: signature.append(sig[i].getName());
103: }
104:
105: return signature.toString();
106: }
107:
108: public final MyOodbProxy createRoot(String rootName, Class classType) {
109: return createRoot(rootName, classType.getName());
110: }
111:
112: public final MyOodbProxy createRoot(String rootName,
113: Class[] classTypes) {
114: return createRoot(rootName, createSignature(classTypes));
115: }
116:
117: public final MyOodbProxy createRoot(String rootName,
118: String className) {
119: return createRoot(rootName, className, (String) null, null);
120: }
121:
122: public final MyOodbProxy createRoot(String rootName,
123: Class classType, String sig, Object[] args) {
124: return createRoot(rootName, classType.getName(), sig, args);
125: }
126:
127: public final MyOodbProxy createRoot(String rootName,
128: Class classType, Class[] sig, Object[] args) {
129: return createRoot(rootName, classType.getName(),
130: createSignature(sig), args);
131: }
132:
133: public final MyOodbProxy createRoot(String rootName,
134: String className, Class[] sig, Object[] args) {
135: return createRoot(rootName, className, createSignature(sig),
136: args);
137: }
138:
139: public final MyOodbProxy createObject(Class classType) {
140: return createObject(classType.getName());
141: }
142:
143: public final MyOodbProxy createObject(Class[] classTypes) {
144: return createObject(createSignature(classTypes));
145: }
146:
147: public final MyOodbProxy createObject(String className) {
148: return createObject(className, (String) null, null);
149: }
150:
151: public final MyOodbProxy createObject(Class classType, String sig,
152: Object[] args) {
153: return createObject(classType.getName(), sig, args);
154: }
155:
156: public final MyOodbProxy createObject(Class classType, Class[] sig,
157: Object[] args) {
158: return createObject(classType.getName(), createSignature(sig),
159: args);
160: }
161:
162: public final MyOodbProxy createObject(String className,
163: Class[] sig, Object[] args) {
164: return createObject(className, createSignature(sig), args);
165: }
166: }
|