Giter Club home page Giter Club logo

jbeanproxy's Introduction

jbeanproxy

A library that enables quick and easy creation of dynamically generated proxy wrappers around Java bean objects which fire an event whenever a setter method has been invoked.

Example

Here we have a class PersonImpl which implements interface Person. The class has two properties: firstName and lastName. What we want to achieve is to have an event fire whenever one of the properties has been changed, but without changing the existing PersonImpl class and without explicitly creating another class. We could have a really large number of such classes or the classes may not even be known at the time.

So, what this library does is to generate a wrapper class implementing the same interface on the fly and redirect all method calls to the original object, except the setter methods which also have to fire the event.

    //create the original bean
    Person real = new PersonImpl();
	real.setFirstName("Chuck");
	real.setLastName("Norris");
		
	BoundBeanFactory factory = new BoundBeanFactory();
	//state which properties we want to track
	factory.setBoundProperties(new String[]{"firstName", "lastName"	});
	factory.setPropertyChangeListener(new DummyPropertyChangeListener());
		
	//now we get the proxy object
	//all tracked setters invoked on this object
	//will fire the event
	Person proxy = factory.createWrapperProxy(real, Person.class);
	
	//try and see
	proxy.setFirstName("Someone");
	proxy.setLastName("Else");

License

Copyright (C) 2013 Goran Jovic

Distributed under the Eclipse Public License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.