Skip to content

Commit 56cb673

Browse files
author
molino.luca@gmail.com
committed
Created the new "object" project and Moved all ObjectDatabase implementation in it.
Added javassist project. Added new ObjectDatabase implementation with proxied instance.
1 parent feda95b commit 56cb673

137 files changed

Lines changed: 7308 additions & 1195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_base/base-build.xml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<!-- Copyright (c) 1999-2010 Luca Garulli - LICENSE: Apache 2.0 -->
3-
<project basedir="." >
4-
<property name="project.src" value="src/main/java" />
3+
<project basedir=".">
4+
<property name="project.src" value="src/main/java" />
55
<property name="project.src2" value="${project.src}" />
66
<property name="project.res" value="src/main/resources" />
77
<property name="project.lib" value="lib" />
@@ -16,16 +16,16 @@
1616
<property name="build.sysclasspath" value="ignore" />
1717

1818
<path id="project.classpath">
19-
<filelist dir=".." files="${project.jar-deps}" />
20-
<fileset dir="${project.lib}" includes="**/*.jar" />
21-
<fileset dir="${project.lib2}" includes="**/*.jar" />
22-
<fileset dir=".." includes="**/target/*.jar" />
19+
<filelist dir=".." files="${project.jar-deps}" />
20+
<fileset dir="${project.lib}" includes="**/*.jar" />
21+
<fileset dir="${project.lib2}" includes="**/*.jar" />
22+
<fileset dir=".." includes="**/target/*.jar" />
2323
</path>
2424

2525
<target name="init">
26-
<echo>-----------------------------------</echo>
27-
<echo>-> ${ant.project.name}</echo>
28-
<echo>-----------------------------------</echo>
26+
<echo>-----------------------------------</echo>
27+
<echo>-> ${ant.project.name}</echo>
28+
<echo>-----------------------------------</echo>
2929
<mkdir dir="${project.build}" />
3030
</target>
3131

@@ -35,9 +35,8 @@
3535
</target>
3636

3737
<target name="compile" depends="init">
38-
<mkdir dir="${project.lib}" />
39-
<javac destdir="${project.build}" debug="${project.is-debug}" debuglevel="${project.debug-level}" target="${project.target-comp}" source="${project.source-comp}"
40-
verbose="false" includeAntRuntime="false">
38+
<mkdir dir="${project.lib}" />
39+
<javac destdir="${project.build}" debug="${project.is-debug}" debuglevel="${project.debug-level}" target="${project.target-comp}" source="${project.source-comp}" verbose="false" includeAntRuntime="false">
4140
<src path="${project.src}" />
4241
<src path="${project.src2}" />
4342
<classpath refid="project.classpath" />
@@ -73,9 +72,9 @@
7372
<target name="install" depends="jar">
7473
<copy todir="${global.lib}">
7574
<fileset dir="${project.dist}" includes="*.jar">
76-
<exclude name="*test*.jar"/>
77-
<exclude name="*-javadoc.jar"/>
78-
<exclude name="*-sources.jar"/>
75+
<exclude name="*test*.jar" />
76+
<exclude name="*-javadoc.jar" />
77+
<exclude name="*-sources.jar" />
7978
</fileset>
8079
</copy>
8180
</target>

build.number

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#Build Number for ANT. Do not edit!
2-
#Sat Apr 28 20:56:54 CEST 2012
3-
build.number=11818
1+
#Build Number for ANT. Do not edit!
2+
#Mon Apr 30 17:37:32 CEST 2012
3+
build.number=11821

build.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
<fileset dir="commons" includes="build.xml" />
2525
<fileset dir="core" includes="build.xml" />
26+
<fileset dir="object" includes="build.xml" />
2627
<fileset dir="enterprise" includes="build.xml" />
2728
<fileset dir="client" includes="build.xml" />
2829
<fileset dir="server" includes="build.xml" />
@@ -94,18 +95,20 @@
9495
overview="overview.html">
9596
<classpath>
9697
<fileset dir=".">
97-
<include name="core/lib/persistence-api-1.0.jar" />
98+
<include name="object/lib/persistence-api-1.0.jar" />
9899
</fileset>
99100
</classpath>
100101
<packageset dir="." defaultexcludes="yes">
101102
<include name="commons/src/main/java/**"/>
102103
<include name="core/src/main/java/**"/>
104+
<include name="object/src/main/java/**/*.java"/>
103105
</packageset>
104106
<fileset dir="." defaultexcludes="yes">
105107
<include name="commons/src/main/java/**/*.java"/>
106108
<include name="core/src/main/java/**/*.java"/>
107109
<include name="client/src/main/java/**/*.java"/>
108110
<include name="enterprise/src/main/java/**/*.java"/>
111+
<include name="object/src/main/java/**/*.java"/>
109112
</fileset>
110113
<doclet name="org.umlgraph.doclet.UmlGraphDoc" path="_base/lib/UmlGraph.jar">
111114
<param name="-hide" value="java.*" />

commons/src/main/java/com/orientechnologies/common/reflection/OReflectionHelper.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,37 @@ public static Class<?> getGenericMultivalueType(final Field p) {
178178
final ParameterizedType pt = (ParameterizedType) genericType;
179179
if (pt.getActualTypeArguments() != null && pt.getActualTypeArguments().length > 0) {
180180
if (((Class<?>) pt.getRawType()).isAssignableFrom(Map.class)) {
181-
if (pt.getActualTypeArguments()[1] instanceof Class<?>)
181+
if (pt.getActualTypeArguments()[1] instanceof Class<?>) {
182182
return (Class<?>) pt.getActualTypeArguments()[1];
183-
} else if (pt.getActualTypeArguments()[0] instanceof Class<?>)
183+
} else if (pt.getActualTypeArguments()[1] instanceof ParameterizedType)
184+
return (Class<?>) ((ParameterizedType) pt.getActualTypeArguments()[1]).getRawType();
185+
} else if (pt.getActualTypeArguments()[0] instanceof Class<?>) {
184186
return (Class<?>) pt.getActualTypeArguments()[0];
187+
} else if (pt.getActualTypeArguments()[0] instanceof ParameterizedType)
188+
return (Class<?>) ((ParameterizedType) pt.getActualTypeArguments()[0]).getRawType();
185189
}
186-
}
190+
} else if (p.getType().isArray())
191+
return p.getType().getComponentType();
187192
}
188193
return null;
189194
}
195+
196+
/**
197+
* Checks if a class is a Java type: Map, Collection,arrays, Number (extensions and primitives), String, Boolean..
198+
*
199+
* @param clazz
200+
* Class<?> to examine
201+
* @return true if clazz is Java type, false otherwise
202+
*/
203+
public static boolean isJavaType(Class<?> clazz) {
204+
if (clazz.isPrimitive())
205+
return true;
206+
else if (clazz.getName().startsWith("java.lang"))
207+
return true;
208+
else if (clazz.getName().startsWith("java.util"))
209+
return true;
210+
else if (clazz.isArray())
211+
return true;
212+
return false;
213+
}
190214
}

core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<artifactId>orientdb-parent</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010
<relativePath>../</relativePath>
11-
</parent>
12-
11+
</parent>
12+
1313
<artifactId>orientdb-core</artifactId>
1414

1515
<name>OrientDB Core</name>
@@ -41,4 +41,4 @@
4141
</dependency>
4242
</dependencies>
4343

44-
</project>
44+
</project>

core/src/main/java/com/orientechnologies/orient/core/OOrientListener.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ public interface OOrientListener {
2828
public void onStorageRegistered(final OStorage iStorage);
2929

3030
public void onStorageUnregistered(final OStorage iStorage);
31+
32+
public void onShutdown();
3133
}

core/src/main/java/com/orientechnologies/orient/core/Orient.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
3636
import com.orientechnologies.orient.core.db.ODatabaseFactory;
3737
import com.orientechnologies.orient.core.db.ODatabaseLifecycleListener;
38-
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool;
39-
import com.orientechnologies.orient.core.db.graph.OGraphDatabasePool;
40-
import com.orientechnologies.orient.core.db.object.ODatabaseObjectPool;
38+
import com.orientechnologies.orient.core.db.ODatabasePoolBase;
4139
import com.orientechnologies.orient.core.engine.OEngine;
4240
import com.orientechnologies.orient.core.engine.local.OEngineLocal;
4341
import com.orientechnologies.orient.core.engine.memory.OEngineMemory;
@@ -50,7 +48,7 @@
5048
import com.orientechnologies.orient.core.storage.fs.OMMapManager;
5149

5250
public class Orient extends OSharedResourceAbstract {
53-
public static final String URL_SYNTAX = "<engine>:<db-type>:<db-name>[?<db-param>=<db-value>[&]]*";
51+
public static final String URL_SYNTAX = "<engine>:<db-type>:<db-name>[?<db-param>=<db-value>[&]]*";
5452

5553
protected Map<String, OEngine> engines = new HashMap<String, OEngine>();
5654
protected Map<String, OStorage> storages = new HashMap<String, OStorage>();
@@ -61,13 +59,15 @@ public class Orient extends OSharedResourceAbstract {
6159
protected OClusterFactory clusterFactory = new ODefaultClusterFactory();
6260
protected volatile boolean active = false;
6361

64-
protected static final OrientShutdownHook shutdownHook = new OrientShutdownHook();
65-
protected static final Timer timer = new Timer(true);
66-
protected static final ThreadGroup threadGroup = new ThreadGroup("OrientDB");
67-
protected static Orient instance = new Orient();
62+
protected static final OrientShutdownHook shutdownHook = new OrientShutdownHook();
63+
protected static final Timer timer = new Timer(true);
64+
protected static final ThreadGroup threadGroup = new ThreadGroup("OrientDB");
65+
protected static Orient instance = new Orient();
6866

69-
private final OMemoryWatchDog memoryWatchDog;
70-
private static AtomicInteger serialId = new AtomicInteger();
67+
private final OMemoryWatchDog memoryWatchDog;
68+
private static AtomicInteger serialId = new AtomicInteger();
69+
70+
protected List<Class<? extends ODatabasePoolBase<?>>> pools;
7171

7272
protected Orient() {
7373
// REGISTER THE EMBEDDED ENGINE
@@ -265,10 +265,10 @@ public void shutdown() {
265265

266266
OLogManager.instance().debug(this, "Orient Engine is shutting down...");
267267

268-
// CLOSE ALL THE GLOBAL DATABASE POOLS
269-
ODatabaseDocumentPool.global().close();
270-
ODatabaseObjectPool.global().close();
271-
OGraphDatabasePool.global().close();
268+
// CALL THE SHUTDOWN ON ALL THE LISTENERS
269+
for (OOrientListener l : listeners) {
270+
l.onShutdown();
271+
}
272272

273273
// CLOSE ALL DATABASES
274274
databaseFactory.shutdown();

core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseComplex.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,16 @@ public enum OPERATION_MODE {
115115
* Fetch plan used
116116
* @param iIgnoreCache
117117
* Ignore cache or use it
118+
* @return The loaded entity
118119
*/
119-
public void reload(final T iObject, String iFetchPlan, boolean iIgnoreCache);
120+
public <RET extends T> RET reload(final T iObject, String iFetchPlan, boolean iIgnoreCache);
120121

121122
/**
122123
* Loads the entity by the Record ID.
123124
*
124125
* @param iRecordId
125126
* The unique record id of the entity to load.
126-
* @return
127+
* @return The loaded entity
127128
*/
128129
public <RET extends T> RET load(ORID iRecordId);
129130

@@ -134,7 +135,7 @@ public enum OPERATION_MODE {
134135
* The unique record id of the entity to load.
135136
* @param iFetchPlan
136137
* Fetch plan used
137-
* @return
138+
* @return The loaded entity
138139
*/
139140
public <RET extends T> RET load(ORID iRecordId, String iFetchPlan);
140141

@@ -147,7 +148,7 @@ public enum OPERATION_MODE {
147148
* Fetch plan used
148149
* @param iIgnoreCache
149150
* Ignore cache or use it
150-
* @return
151+
* @return The loaded entity
151152
*/
152153
public <RET extends T> RET load(ORID iRecordId, String iFetchPlan, boolean iIgnoreCache);
153154

@@ -157,9 +158,9 @@ public enum OPERATION_MODE {
157158
*
158159
* @param iObject
159160
* The entity to save
160-
* @return The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
161+
* @return The saved entity.
161162
*/
162-
public ODatabaseComplex<T> save(T iObject);
163+
public <RET extends T> RET save(T iObject);
163164

164165
/**
165166
* Saves an entity specifying the mode. If the entity is not dirty, then the operation will be ignored. For custom entity
@@ -169,9 +170,9 @@ public enum OPERATION_MODE {
169170
* The entity to save
170171
* @param iMode
171172
* Mode of save: synchronous (default) or asynchronous
172-
* @return The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
173+
* @return The saved entity.
173174
*/
174-
public ODatabaseComplex<T> save(T iObject, OPERATION_MODE iMode);
175+
public <RET extends T> RET save(T iObject, OPERATION_MODE iMode);
175176

176177
/**
177178
* Saves an entity in the specified cluster in synchronous mode. If the entity is not dirty, then the operation will be ignored.
@@ -181,9 +182,9 @@ public enum OPERATION_MODE {
181182
* The entity to save
182183
* @param iClusterName
183184
* Name of the cluster where to save
184-
* @return The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
185+
* @return The saved entity.
185186
*/
186-
public ODatabaseComplex<T> save(T iObject, String iClusterName);
187+
public <RET extends T> RET save(T iObject, String iClusterName);
187188

188189
/**
189190
* Saves an entity in the specified cluster specifying the mode. If the entity is not dirty, then the operation will be ignored.
@@ -195,9 +196,9 @@ public enum OPERATION_MODE {
195196
* Name of the cluster where to save
196197
* @param iMode
197198
* Mode of save: synchronous (default) or asynchronous
198-
* @return The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
199+
* @return The saved entity.
199200
*/
200-
public ODatabaseComplex<T> save(T iObject, String iClusterName, OPERATION_MODE iMode);
201+
public <RET extends T> RET save(T iObject, String iClusterName, OPERATION_MODE iMode);
201202

202203
/**
203204
* Deletes an entity from the database in synchronous mode.

core/src/main/java/com/orientechnologies/orient/core/db/ODatabasePoolBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public void setup(final int iMinSize, final int iMaxSize) {
4141
if (dbPool == null) {
4242
dbPool = new ODatabasePoolAbstract<DB>(this, iMinSize, iMaxSize) {
4343

44+
public void onShutdown() {
45+
if (owner instanceof ODatabasePoolBase<?>)
46+
((ODatabasePoolBase<?>) owner).close();
47+
}
48+
4449
public DB createNewResource(final String iDatabaseName, final Object... iAdditionalArgs) {
4550
if (iAdditionalArgs.length < 2)
4651
throw new OSecurityAccessException("Username and/or password missed");

core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordWrapperAbstract.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,33 +208,30 @@ public <RET extends ORecordInternal<?>> RET load(final ORecordInternal<?> iRecor
208208
return (RET) underlying.load(iRecord, iFetchPlan, iIgnoreCache);
209209
}
210210

211-
public void reload(final ORecordInternal<?> iRecord) {
212-
underlying.reload(iRecord, null, true);
211+
public <RET extends ORecordInternal<?>> RET reload(final ORecordInternal<?> iRecord) {
212+
return (RET) underlying.reload(iRecord, null, true);
213213
}
214214

215-
public void reload(final ORecordInternal<?> iRecord, final String iFetchPlan, final boolean iIgnoreCache) {
216-
underlying.reload(iRecord, iFetchPlan, iIgnoreCache);
215+
public <RET extends ORecordInternal<?>> RET reload(final ORecordInternal<?> iRecord, final String iFetchPlan,
216+
final boolean iIgnoreCache) {
217+
return (RET) underlying.reload(iRecord, iFetchPlan, iIgnoreCache);
217218
}
218219

219-
public ODatabaseComplex<ORecordInternal<?>> save(final ORecordInternal<?> iRecord) {
220-
underlying.save(iRecord);
221-
return this;
220+
public <RET extends ORecordInternal<?>> RET save(final ORecordInternal<?> iRecord) {
221+
return (RET) underlying.save(iRecord);
222222
}
223223

224-
public ODatabaseComplex<ORecordInternal<?>> save(final ORecordInternal<?> iRecord, final String iClusterName) {
225-
underlying.save(iRecord, iClusterName);
226-
return this;
224+
public <RET extends ORecordInternal<?>> RET save(final ORecordInternal<?> iRecord, final String iClusterName) {
225+
return (RET) underlying.save(iRecord, iClusterName);
227226
}
228227

229-
public ODatabaseComplex<ORecordInternal<?>> save(final ORecordInternal<?> iRecord, final OPERATION_MODE iMode) {
230-
underlying.save(iRecord, iMode);
231-
return this;
228+
public <RET extends ORecordInternal<?>> RET save(final ORecordInternal<?> iRecord, final OPERATION_MODE iMode) {
229+
return (RET) underlying.save(iRecord, iMode);
232230
}
233231

234-
public ODatabaseComplex<ORecordInternal<?>> save(final ORecordInternal<?> iRecord, final String iClusterName,
232+
public <RET extends ORecordInternal<?>> RET save(final ORecordInternal<?> iRecord, final String iClusterName,
235233
final OPERATION_MODE iMode) {
236-
underlying.save(iRecord, iClusterName, iMode);
237-
return this;
234+
return (RET) underlying.save(iRecord, iClusterName, iMode);
238235
}
239236

240237
public void setInternal(final ATTRIBUTES attribute, final Object iValue) {

0 commit comments

Comments
 (0)