dynamic-proxy

How to use Dynamic Proxies with JSF when the method signature contains Object … args

本秂侑毒 提交于 2019-12-24 13:33:32
问题 I'm having some trouble with Spring, JPA and Dynamic Proxy DAO classes which are initialized as Spring Beans. This particular project has been plaguing me on the persistence/transaction side for some time, and I'd like to get this nailed down once and for all. First, here's a method from the DAO interface: /** * Perform a named query using numbered parameters and return the results as a list * @param name * @param params * @return query results */ List getNQasList(String name, Object...

aop performance on spring (idk, aspectj)

妖精的绣舞 提交于 2019-12-23 04:09:13
问题 I tried to test the performance of AOP on Spring framework 4.1.6 and AOP methods were clean, jdk dynamic proxy and aspectJ. I made one to five simple advices to them and checked elapsed time for each. result: jdk dynamic proxy: aspect1: 2.499 sec. aspect2: 2.574 aspect3: 2.466 aspect4: 2.436 aspect5: 2.563 aspectJ (ctw): aspect1: 2.648 aspect2: 2.562 aspect3: 2.635 aspect4: 2.520 aspect5: 2.574 clean (no aspect): aspect1: 2.699 aspect2: 2.513 aspect3: 2.527 aspect4: 2.458 aspect5: 2.402

Detailed ServiceDescription / Proxy from WSDL

为君一笑 提交于 2019-12-23 03:01:48
问题 I am using the classes ServiceDescription / ServiceDescriptionImporter to dynamically call web services. I'd like to dig a bit deeper into the WSDL description and get 1) Parameter info for each of the web methods 2) The actual types / composition each parameters of all the web methods (ie if a WebMethod takes some complex type as a parameter, I need to know the primitive / other types it is composed of as well, if possible) Here is the code I have for the dynamical call: public static object

What's the best way to implement a dynamic proxy in C#?

三世轮回 提交于 2019-12-21 05:31:23
问题 I've got a need to create a dynamic proxy in C#. I want this class to wrap another class, and take on it's public interface, forwarding calls for those functions: class MyRootClass { public virtual void Foo() { Console.Out.WriteLine("Foo!"); } } interface ISecondaryInterface { void Bar(); } class Wrapper<T> : ISecondaryInterface where T: MyRootClass { public Wrapper(T otherObj) { } public void Bar() { Console.Out.WriteLine("Bar!"); } } Here's how I want to use it: Wrapper<MyRootClass>

How to unwrap the original object from a dynamic proxy

谁都会走 提交于 2019-12-19 05:44:51
问题 what's the best approach to unwrap a dynamic proxy to retrieve the original object beneath? The dynamic proxy has been created using java.lang.reflect.Proxy.newProxyInstance() Thank you. 回答1: Each proxy has an InvocationHandler associated with it. Only the InvocationHandler knows which object ( if any ) underlies the proxy. If you control the creation of the proxy, then you can supply your own InvocationHandler that will have the extra functionality that you desire (i.e. will be able to

Implementing equals() with JDK Dynamic Proxies

十年热恋 提交于 2019-12-14 00:57:45
问题 For the first time ever, I have to implement my own proxy classes using the standard JDK Dynamic Proxy. It works fairly well, except for one detail: the equals(...) method. Let's assume that we have a simple Interface like this, which we want to proxy: public interface MyInterface { public String getID(); public void setID(String id); } ... and our implementation looks like this (standard Java Bean with generated hashCode() and equals ): public class MyImplementation implements MyInterface {

PHP: Overriding parent methods with __call

匆匆过客 提交于 2019-12-12 18:05:04
问题 I'd like to hide parent methods in some manner so that a child class's __call magic method is invoked for methods defined on the parent. For example: class C { function foo() { echo "foo\n"; } } class D extends C { function __call( $method, $args ) { echo "called $name\n"; } } $d = new D(); $d->foo(); // desired result: called foo // actual result: foo I've checked into rename_function and override_function but those don't work for methods. ReflectionMethod has a setAccessible method I tried,

Self-proxying constructor with Castle?

╄→гoц情女王★ 提交于 2019-12-12 05:13:12
问题 Is it possible for a class's constructor to wrap a proxy around itself? This code, unfortunately, causes a StackOverflowException. void Main() { var thing = new Thing(); } public static readonly ProxyGenerator generator = new ProxyGenerator(); public class Thing { public Thing() { generator.CreateClassProxyWithTarget(this); } } I want some way to guarantee that new instances of my class are wrapped in the proxy instead of having to create some kind of factory that creates proxied instance.

A Java config analog of XML configuration not working

北城余情 提交于 2019-12-11 15:27:50
问题 TL/DR: The problem boils down to creating a custom Spring scope, injecting a prototype -like scoped bean into a singleton with proxyMode = ScopedProxyMode.TARGET_CLASS but still getting a singleton in the Java config version of the configuration (whereas it works fine with XML). UPDATE: Problem solved, see answer. I'm using jBehave to write BDD test scenarios for our Spring application. We recently thought that we need independence in executing test scenarios (meaning that test context has to

Proxy pattern vs. overriding

女生的网名这么多〃 提交于 2019-12-10 17:11:04
问题 Suppose there is a interface Subject. interface Subject { void request(); } We have a RealSubject class. Suppose we want to enhance RealSubject, we can either use Proxy pattern that wraps around a RealSubject: class Proxy implements Subject { private RealSubject ref; void request(){ ... } } or we can extends RealSubject and override the method class EnhancedSubject extends RealSubject { @Override void request() { ... } } Which approach is better? I'm aware of Liskov principle; let's suppose