]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/request/ResourceReadBase.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / ResourceReadBase.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.common.request;
13
14 import org.simantics.db.AsyncRequestProcessor;
15 import org.simantics.db.RequestProcessor;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.procedure.AsyncListener;
18 import org.simantics.db.procedure.AsyncProcedure;
19 import org.simantics.db.procedure.Listener;
20 import org.simantics.db.procedure.Procedure;
21 import org.simantics.db.procedure.SyncListener;
22 import org.simantics.db.procedure.SyncProcedure;
23 import org.simantics.db.request.Read;
24 import org.simantics.db.request.ReadExt;
25 import org.simantics.db.request.ReadInterface;
26 import org.simantics.db.request.RequestFlags;
27
28 public abstract class ResourceReadBase<T> implements Read<T>, ReadInterface<T>, ReadExt {
29
30     @Override
31     public void request(AsyncRequestProcessor processor, AsyncProcedure<T> procedure) {
32         processor.asyncRequest(this, procedure);
33     }
34     
35     @Override
36     public void request(AsyncRequestProcessor processor, Procedure<T> procedure) {
37         processor.asyncRequest(this, procedure);
38     }
39     
40     @Override
41     public void request(AsyncRequestProcessor processor, SyncProcedure<T> procedure) {
42         processor.asyncRequest(this, procedure);
43     }
44
45     @Override
46     public void request(AsyncRequestProcessor processor, AsyncListener<T> procedure) {
47         processor.asyncRequest(this, procedure);
48     }
49     
50     @Override
51     public void request(AsyncRequestProcessor processor, Listener<T> procedure) {
52         processor.asyncRequest(this, procedure);
53     }
54     
55     @Override
56     public void request(AsyncRequestProcessor processor, SyncListener<T> procedure) {
57         processor.asyncRequest(this, procedure);
58     }
59     
60     @Override
61     public T request(RequestProcessor processor) throws DatabaseException {
62         return processor.syncRequest(this);
63     }
64     
65     @Override
66     public int getType() {
67         return RequestFlags.INVALIDATE;
68     }
69     
70     protected int classHash() {
71         return 31*getClass().hashCode();
72     }
73     
74 }