Skip to main content
summaryrefslogtreecommitdiffstats
blob: d26f67dd0aa73747680e65427098fdda98f98f25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jem.internal.proxy.remote;
/*
 *  $RCSfile: REMConstantBeanProxy.java,v $
 *  $Revision: 1.6 $  $Date: 2005/08/24 20:39:06 $ 
 */


import org.eclipse.jem.internal.proxy.common.remote.Commands;
import org.eclipse.jem.internal.proxy.core.IBeanProxy;
import org.eclipse.jem.internal.proxy.core.ProxyFactoryRegistry;
/**
 * This is a base for bean proxies that are constants and
 * do not have an object on the remote VM side. They are
 * shipped back and forth by value.
 */

public abstract class REMConstantBeanProxy implements IREMConstantBeanProxy {
	protected final REMProxyFactoryRegistry fFactory;
	private final static Integer ID = new Integer(Commands.NOT_AN_ID);
	
	protected REMConstantBeanProxy(REMProxyFactoryRegistry aFactory) {
		fFactory = aFactory;
	}
	/**
	 * Return the registry this proxy was created with.
	 */
	public ProxyFactoryRegistry getProxyFactoryRegistry() {
		return fFactory;
	}
	
	/**
	 * equals: Equal if:
	 *         1) This proxy == (identity) to the other object
	 *         2) Else if other is an IBeanProxy and not a constant one, then if
	 *            equals on the server.
	 *         3) If this is a constant proxy and the other is too or is a constant
	 *            value (e.g. IStringBeanProxy.equals(String), then true if values are equals.
	 * This is abstract because each type needs to do a unique test for equality.
	 */
	public abstract boolean equals(Object anObject);
	
	/* (non-Javadoc)
	 * @see org.eclipse.jem.internal.proxy.core.IBeanProxy#sameAs(org.eclipse.jem.internal.proxy.core.IBeanProxy)
	 */
	public boolean sameAs(IBeanProxy aBeanProxy) {
		// We can't be assured that there are not non-identical constants that are actually identical.
		// This is because for constants we do not know the id of the original. That is not sent across from the vm.		
		return this == aBeanProxy;	
	}	
	
	/**
	 * Return the ID of this proxy.
	 * Constants have no id's, so we return -1.
	 */
	public Integer getID() {
		return ID;
	}
	
	/**
	 * isValid. Constant ones are always valid unless the registry is terminated, except if an
	 * override releases resources. In that case the overriding
	 * subclass should also override isValid() to return false
	 * if release() was called.
	 */
	public boolean isValid() {
		return fFactory.isValid();
	}
	
	/**
	 * release. Constant ones don't need to typically be released, however
	 * if an override does do something to release, then it MUST also
	 * override isValid() to return false.
	 */
	public void release() {
	}


	/* (non-Javadoc)
	 * @see org.eclipse.jem.internal.proxy.core.IProxy#isBeanProxy()
	 */
	public final boolean isBeanProxy() {
		return true;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jem.internal.proxy.core.IProxy#isExpressionProxy()
	 */
	public final boolean isExpressionProxy() {
		return false;
	}
}

Back to the top