A proxy class is a class functioning as an interface to another class or a service. Proxy classes are implementation of Proxy design pattern. These classes help using large objects or other resources that are expensive or impossible to duplicate.
Questions tagged [proxy-classes]
342 questions
116
votes
2 answers
What is a Proxy in Doctrine 2?
I just finished reading all the Doctrine 2 documentation, I started my own sandbox, I understood most of the principes, but there is still a question and I couldn't find any complete explanation in the doc.
What are Proxy classes?
When should I…

Jérémy
- 1,161
- 2
- 8
- 3
105
votes
7 answers
Typescript "this" inside a class method
I know this is probably painfully basic, but i am having a tough time wrapping my head around it.
class Main
{
constructor()
{
requestAnimationFrame(this.update); //fine
}
update(): void
{
…

Clark
- 2,598
- 3
- 27
- 41
85
votes
4 answers
What are the downsides to turning off ProxyCreationEnabled for CTP5 of EF code first
The only way that my WCF service can return classes from a code first model is by setting the ProxyCreationEnable to false using the code below.
((IObjectContextAdapter)MyDb).ObjectContext.ContextOptions.ProxyCreationEnable = false;
What are the…

Ralph Shillington
- 20,718
- 23
- 91
- 154
37
votes
9 answers
Dynamically generate classes at runtime in php?
Here's what I want to do:
$clsName = substr(md5(rand()),0,10); //generate a random name
$cls = new $clsName(); //create a new instance
function __autoload($class_name)
{
//define that instance dynamically
}
Obviously this isn't what I'm actually…

Will Shaver
- 12,471
- 5
- 49
- 64
32
votes
9 answers
Fixing BeanNotOfRequiredTypeException on Spring proxy cast on a non-singleton bean?
I'm having an issue with pulling a Spring bean from an application context.
When I try;
InnerThread instance = (InnerThread) SpringContextFactory.getApplicationContext().getBean("innerThread", InnerThread.class);
I…

James McMahon
- 48,506
- 64
- 207
- 283
32
votes
5 answers
Right way to return proxy model instance from a base model instance in Django?
Say I have models:
class Animal(models.Model):
type = models.CharField(max_length=255)
class Dog(Animal):
def make_sound(self):
print "Woof!"
class Meta:
proxy = True
class Cat(Animal):
def make_sound(self):
…

sotangochips
- 2,700
- 6
- 28
- 38
27
votes
2 answers
How to know original class name if wrapped into proxy by Spring?
I am trying to obtain some classes name by getClass().getSimpleName() under Spring and it returns something like
MyClass$$EnhancerBySpringCGLIB$$SOMEHEX
This is probably because Spring wraps the class into proxy.
Is there any portable way to…

Dims
- 47,675
- 117
- 331
- 600
26
votes
3 answers
Can I use reflection with RealProxy instances?
I'm quite sure I'm missing some constraint or caveat somewhere, but here's my situation. Assume I have a class that I want to have a proxy for, like the following:
public class MyList : MarshalByRefObject, IList
{
private List…

JimEvans
- 27,201
- 7
- 83
- 108
24
votes
3 answers
Generating a JS-client based on a ASP.NET WebAPI Controller
In modern web-projects that use RESTful API's we often see AJAX-calls like the one below littered around our JavaScript-files.
$.ajax({
type: "POST",
url: myapp.baseUrl + 'Api/Note',
data: ko.mapping.toJSON(note),
contentType:…

Martin Devillers
- 17,293
- 5
- 46
- 88
22
votes
2 answers
Why does Django create migration files for proxy models?
I just created a proxy model and was surprised that manage.py makemigrations creates a new migration file with a migrations.CreateModel operation.
A proxy model does not create a new database table, it's just a different python interface to the same…

Maxime R.
- 9,621
- 7
- 53
- 59
18
votes
3 answers
Add service reference to ASP.NET Web API service
I've got an MVC solution that hosts a few routes for Web API services. In some situations, I will call these from JavaScript with a simple HTTP get. In others, I want to call them from some .NET code, perhaps another MVC application.
Is there a way…

Daniel Revell
- 8,338
- 14
- 57
- 95
18
votes
1 answer
Under what conditions will `RealProxy.GetTransparentProxy()` return `null`?
The documentation at http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.gettransparentproxy%28v=VS.100%29.aspx doesn't indicate a scenario where GetTransparentProxy will return null, but I'm getting a null back when I…

David Pfeffer
- 38,869
- 30
- 127
- 202
13
votes
1 answer
Object.assign and proxies
Having the following object:
let obj = { id: 0 };
and the following Proxy:
let objProxy = new Proxy(obj, {
get: (target, name) => {
if (name == "id")
return "id from proxy";
}});
Is it possible to "retain" the Proxy after an…

Philip Kamenarsky
- 2,757
- 2
- 24
- 30
13
votes
3 answers
Django proxy model to different database
Situation
We have a few different applications which use tickets from a ticket support system for different kinds of functionality.
First of all we have an application which has a few models that represent the models of our ticket support system…

Bono
- 4,757
- 6
- 48
- 77
13
votes
2 answers
Can't set "apply" trap to Proxy object
I created a Proxy object with an "apply" trap:
var target = {},
handler = { apply: () => 42 }
proxy = new Proxy(target, handler);
proxy(); // TypeError: proxy is not a function
Therefore, the Proxy object should be callable. However, it…

Oriol
- 274,082
- 63
- 437
- 513