Annotation Agnostic Domain Objects

Hi,
I would like to know how we create annotation agnostic domain objects. At present, i have to DPL annotations in my domain object for persisting in BDB. Siince, i will be sharing
the domain objects with other projects which may or may not use BDB. So I would like to have annotation agnostic domain objects.
Is there a way to do it in BDB? I know its possible to do it with Base API. But i would like to know whether its possible it in DPL itself.
In BDB forums, there were some leads to use EntityModel and AnnotationModel which are not clear to use. I would like to have more example on this, if it is possible to do it by EntityModel or AnnotationModel.
Any help on this is Highly Appreciated.
Thanks
William

Hi William,
Just to make sure I understand your question. You basically want to have plain domain objects, non-annotated (non DPL annotated) POJOs representing the domain objects, and you want to use them with JE's DPL, without adding the DPL specific annotations to persist the objects (something similar to what you would do with Hibernate's mapping documents). Correct?
Regards,
Andrei

Similar Messages

  • Automatic generation of domain objects and database population framework

    Hi, I've been working on my own project for a while now, having a good picture of what my business model should be and what domain should back it up I've run across an issue which I guess is very common in the community: What happens with all this objects in the domain?
    To test them against a database I've to generate some of them, persist them and then run various operations to see if they work properly. The problem is that generating them and then populating your local database can be tedious at times. So I came up with this idea (maybe not a original one, it never is) to create a tool (a framework maybe) capable of feeding on POJOs inside JARs or some other class resource, creating mappings to generators (which are, of course, generic and use reflection to do their work) and then run all those generators a number of times placing their output into several sets and then persist the objects inside those sets using an EntityManager. All the dependencies must be provided at runtime, the tool does not have to know which are those classes it has to generate instances for.
    Generating them through reflection shouldn't be much of a problem if I do it straightforward, the key of the matter is that it cannot be as straightforward as I would like it to be, for every class in the provided JARs I've to match them with configuration properties defined somewhere (XML maybe or Annotations which this object should already have) because not every field on the instance can be initialized the same way, and I don't mean their type either since I can know it through reflection, but many of these objects have database constraints declared, for example, and I've to take that into account when initializing the fields that are constrained.
    Also on occasion I would like to have a class generated with data extracted from another source and not hardcoded into the generators (an XLS for example) which can be very practical for my production environment. Taking all of these into consideration I can see how my development time has increased tenfold.
    Anyway, my question is simple. Do any of you know an utility or framework which could at least facilitate some of these tasks?

    I think the usual way to test items is via JUnit. There are also other test suites based on JUnit such as JSUnit (for javascript testing), cactus, etc.
    For testing, I try to test each object in isolation. For testing DAO objects, in each test, I write some test data to the development database (not production database), perform my test, then remove the test data (cleanup). I put the cleanup in a finally block to ensure it always runs (in case an exception is thrown). An alternative is to use mock objects (search google for something like 'java mock objects database junit'). Also in each test, I do the asserts that exercise the object as they would normally work first, followed by abnormal conditions, followed by conditions that may throw exceptions (if you want to test to that degree). You also might want to add code to automatically block the JUnit tests if it detects its running against production instead of development.

  • Domain Object and Service oriented pattern

    We have J2EE based application with following components, we are facing some issues with existing system.
    Current System : We have J2EE based application. The following is the flow.
    Client Layer [including JSP, Struts ] action classes  Delegates  Session fa�ade [Session bean]  DAO EJBDAO  EJB. We use CMP, xDoclets , JBOSS.
    1.     Our Domain objects are heavy. I know they are suppose to be coarse objects but they take more time in loading. Also, we noticed one thing that lot of methods are called during Domain Object creation process and it takes lot of time in loading. Actually, we dont really know what is happening as we are using CMPs.
    Question :
    -     Any input on what can be done to avoid Domain object excessive loading time.
    -     Anyone can share there experiences with Domain objects. Are you facing issues related with performance.
    -     We dont use DTO, we pass domain objects between. Do you see any problem in doing that.
    2.     Currently, our system was used by one single front end or lets say we have only one client but soon we will have more clients using it.
    Question :
    -     What should be our design approach. How can we make our system more like service oriented. If the two clients demand different business logic then how it will be handled. Business logic common to all the clients will be handled by which layer and business logic specific to client will be handles by which layer.
    -     Please suggest based on our existing infrastructure. We don�t want to use SOAP or cannot make drastic changes to our flow.
    We have domain and services in the same package and we are doing the refactoring of code, your inputs will be valuable.
    Thanks
    Sandipan

    What type of logger do you use and what is the loger-level during production?
    If it is log4j set the logger to level INFO or WARN.
    This might sound trivia but can make a difference between 20seconds and 500 ms.

  • Using domain object instead of generated ones?

    I'm using NetBeans, and I'm curious if there's a way that we can use our domain objects with the web service calls rather than the empty stubs generated by wsgen?
    wsgen creates the skeletal client classes, as well as an ObjectFactory that returns instances of those classes. I imagine I could modify ObjectFactory to return our domain objects instead, but then we'd be breaking with wsgen.
    Is there a better solution to this?
    Thanx!

    You can associate a Virtual Host to the loopback IP address 127.0.0.1 read about Virtual Hosts here: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
    But with the above configuration alone you can access your app via http://somedomainname.com only on your local machine, no one else on the internet will see it.

  • DAO and Domain Object

    hi,
    Normally when i want to persist a domain object like Customer object to a database, my statements will be below,
    // code from my facade
    Customer cust = new Customer();
    cust.setFirstName("myname");
    cust.setLastName("mylastname");
    // set another attributes
    cust.create();
    with this code i have a CustomerPersistence object to handler for create this customer record to a database. Now j2ee have a DAO pattern. So my question is,
    1.where is a domain object within DAO pattern? --> because of we can reused domain object.
    2.DTO is Domain Object, isn't it?
    3.when i look at some articles about DAO, many of it will present in this way
    facade -->create DTO --> call DAO (plus something about factory pattern)
    i never see something like this
    facade --> domain object --> dao
    any suggestion?
    anurakth
    sorry for my english!!

    Hi,
    I am a bit confused about implementation of the domain model and I wondered if you could help. My main concern is that I am introducing too many layers and data holders into the mix. Here is what I am thinking.
    DTO - used to carry data between the presentation and the services layer
    Service Class - coordinates the calling of domain objects
    Domain Object - models a domain entity, service layer logic specific to this object is to be implemented here.
    Data Object - an exact representation of a database table. many to many relationship between domain object and data object.
    Hibernate DAO Class - has no properties, just methods used for read and writing the object to the database. It is passed in the Data Object for persistence. Is it wrong that the DAO contains no properties?
    Perhaps the domain object will contain each data object it is comprised of. I was originally going to keep calls to DAOs in the Services class (as recommended in http://jroller.com/page/egervari/20050109#how_to_change_services_logic ) but I am thinking that each domain object could expose a save method, and that method would co-ordinate persisting itself to the various tables it is derived from.
    Does this sound resonable? I have trouble finding a pattern on the net that clealy defines the Domain Model. I was tempted to map Domain Objects directly to database tables, and simply persist the Domain Object, but this 1-1 relationship may not always hold true.
    Thanks.

  • Help regarding Domain Object.

    Hi,
    I have a question regarding the domain object. I have a form where there some multiple entries for some fields . The domain object is return mapping to the database fields. How should the domain object be changed to handle multiple fields so that multiple inserts can be done.. Can the domain object be coded as an array type. or how the coding needs to be done..I am using JPA
    If some one knows please post it..
    Thanks,

    sahir,
    check the triggering point of your user exit.
    make sure to use a exit/BADI which triggers right after you press 'SAVE'
    thank you.

  • Adding domain objects

    Hello,
    I'm working with an application where we have many, many, many domain objects that could be added to a "header". In my business/service interface I don't like to write 50+ of addX(...), addY(...), addZ(...) etc. methods.
    Every domain object extends a domain object base class. In my business/service interface I've added one single method for adding domain objects to make the interface somewhat smaller:
    public void add(DomainObject[] someDomainObjects);
        ...The elements of the domain object array are of different kind, but all extends the domain object base class. I'd like to implement class and method that have a strategy for determining what kind of domain object the current one is in the given array and invoke the correct add(...) method for that particular domain object.
    The most simple way of doing it is to have a very big if-else using instanceof to determine what kind of domain object it is, but it doesn't feel like a very nice design.
    Example:
    public class MyBusinessObject {
        public void add(DomainObject[] someDomainObjects) {
            // Iterate over all domain objects in the array
            for (DomainObject domainObject : someDomainObjects) {
                // Determine what kind of domain object it is and create the correct DAO
                if (domainObject instanceof X) {
                    DomainObjectXDao xDao = new DomainObjectXDao();
                    // Save the current domain object
                    xDao.save((X) domainObject);
                } else if (domainObject instanceof Y) {
                    DomainObjectYDao yDao = new DomainObjectYDao();
                    // Save the current domain object
                    yDao.save((Y) domainObject);
                } else if (domainObject instanceof Z) {
                    DomainObjectZDao zDao = new DomainObjectZDao();
                    // Save the current domain object
                    zDao.save((Z) domainObject);
                } else if (...) {
    }Is there any design pattern for making this a more nice design?
    If anyone could contribute with their good knowledge I'd be very glad!
    Regards, Andreas Eriksson

    Map the DomainObject types to their respective DAOs and look them up as you loop through them in the add method, e.g.:
    public class MyBusinessObject {
      private Map daos = new HashMap();
        daos.put(X.class, new XDomainTypeDAO());
        daos.put(Y.class, new YDomainTypeDAO());
        daos.put(Z.class, new ZDomainTypeDAO());
      public void add(DomainObject[] objs) {
        for (DomainObject obj : objs) {
          Class type = obj.getClass();
          DAO dao = (DAO) daos.get(type);
          if (dao == null) {
            throw new IllegalArgumentException(
              "No DAO configured for DomainObject type " + type);
          dao.save((DomainObject) obj);
    }You'd have to create a DAO interface (or abstract base class) which defines a save method with the signature public void save(DomainObject obj). Then each DAO would have to implement this method and cast the passed domain object to the expected type.
    To take things further, you could introduce a DAOProvider interface to hide where the MyBusinessObject obtains the DAOs from (rather than have it maintain the map), e.g.:
    public interface DAOProvider {
      DAO daoFor(Class domainType);
    // A really simple implementation - assmes that DAOs are thread-safe
    public class SimpleDAOProvider implements DAOProvider {
      private Map daos = new HashMap();
        daos.put(X.class, new XDomainTypeDAO());
        daos.put(Y.class, new YDomainTypeDAO());
        daos.put(Z.class, new ZDomainTypeDAO());
      public DAO daoFor(Class domainType) {
         DAO dao = (DAO) daos.get(type);
         if (dao == null) {
           throw new IllegalArgumentException(
             "No DAO configured for DomainObject type " + domainType);
        return dao;
    }The advantage of this is you can alter the strategy for handing out DAOs, e.g. pass the same instance back each time, or dynamically instantiate a new instance, etc. Of course, you need a way for the MyBusinessObject to get hold of a DAOProvider instance (inject it? Have it use a factory?)

  • Bean vs Domain Object Responsibility

    Any thoughts out there regarding the decision point on when to put functionality into a domain object (Customer, Order, Address, etc.) versus when to put it into an EJB that you plan to use? You usually start defining your object model and as you create sequence diagrams or collab. diagrams, you begin assigning methods to the classes. But at what point do you decide that functionality does NOT belong in the domain object and instead belongs outside of that object? EJBs have the ability to perform a lot of the work in an N-Tier system, so how do you draw the line on where the functionality goes? Any articles on the subject?
    Thnx.
    Dave

    Any thoughts out there regarding the decision point on
    when to put functionality into a domain object
    (Customer, Order, Address, etc.) versus when to put it
    into an EJB that you plan to use? When you need to access system resources, like connecting to the database, you may place the functionality in EJB. When you need to perform task of processing the domain object related information like the net purchase of the customer then you place the functionality in the domain object.
    You usually start
    defining your object model and as you create sequence
    diagrams or collab. diagrams, you begin assigning
    methods to the classes. But at what point do you
    decide that functionality does NOT belong in the
    domain object and instead belongs outside of that
    object? EJBs have the ability to perform a lot of the
    work in an N-Tier system, so how do you draw the line
    on where the functionality goes? Any articles on the
    subject?
    Thnx.
    DaveThats my opinion.
    Best Regards,
    Amitabh Choudhury.

  • What is a Domain Object?

    I checked dozens of internet pages but didn't find an answer on that question.

    Domain is everything meaningful in the scope of
    current task, thus domain object is an abstraction of
    the real or imaginable entity from the scope of
    current task.Can you please give me an example?
    I will now explain a little bit why I am asking. But please don't forget to give me an example.
    We use the root object as a domain object. "Article" is a domain object in our company. An Article has a 1:m relationship with a "PackageUnit". The PackageUnit is no domain object. Furthermore the PackageUnit has a 1:m relationship with SalesHistoryWeek (which is no domain object too) and so on.
    Only the domain object (Article) can create new instances of the objects which are linked to it (PackageUnit and so on). A PackageUnit cannot create a new instance of SalesHistoryWeek, only Article can do this, the domain object.
    Furthermore only the domain object has getter and setter methods for the linked non domain objects. So the domain object "jumps" over many knots to get or set an object.
    I think this is a strange design and so I am asking here for the meaning of domain objects. Besides this, the coupling of objects is very large in my example and it doesn't respect the Law of Demeter.
    What do you think?

  • Domain object

    Hello!
    I use Spring back-end layer, when I communicate domain
    objects(Flex - Java), on the server I have zero in int, double
    fields, on the client this fields are declared as int and Number.
    Only String type transfer correctly!!!
    How I can resolve this problem?
    //Flex d-o
    [Bindable]
    [RemoteClass(alias="com.home.flex.bean.GoodsBN")]
    public class Goods
    public var idGoods:int;
    public var code:int;
    public var name:String;
    public var weight:int;
    public var type:String;
    public var category:String;
    public var incomeDate:Date;
    public var description:String;
    public var price:Number;
    public function Goods()
    //Java d-o
    public class GoodsBN //implements Serializable
    private int idGoods;
    private int code;
    private String name;
    private int weight;
    private String type;
    private String category;
    private Date incomeDate;
    private String description;
    private double price;
    public GoodsBN()
    ///getter and setter.....

    "vscmaster" <[email protected]> wrote in
    message
    news:gii9eo$4dl$[email protected]..
    > Hello!
    > I use Spring back-end layer, when I communicate domain
    objects(Flex -
    > Java),
    > on the server I have zero in int, double fields, on the
    client this fields
    > are
    > declared as int and Number.
    >
    > Only String type transfer correctly!!!
    >
    > How I can resolve this problem?
    I think Number _is_ the AS3 equivalent of Double

  • Shoul I have my backing beans extend my domain objects?

    Hi,
    In our JSF application, most of our backing beans have the same properties that a corresponding domain object.
    In order to have a clear separation between layers, we have a set of view objects and a separate set of domain objects. Once we populate the backing bean, we copy the value of properties to the domain object.
    Since all the properties of my domain object are duplicated in my backing beans, we were wondering if it is a good (or bad) idea to extend (inherit) my backing beans from my domain objects, and pass the backing beans to my persistence and business layers. This will save us some work.
    Thanks a lot for the advice.
    Mauricio L.

    I think I've solved my own issue though I'm not sure if it is the correct way to accomplish the task at hand.
    When the button for login is clicked and the logginButton_action() method is called inside of my login_jsp_backing class I do the following:
    User user = new User();
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("User", user);
    return user.doLogin(this.getInputUsername().getValue().toString(), this.getInputPassword().getValue().toString());
    (The String return of this method in User is a navigation rule I've setup in my faces-config)
    So my new question is that "Is this best practice?" or should I be doing it differently?
    Message was edited by:
    Steve Carlson

  • How to bind Hibernate domain objects to the UI layer

    Dear All,
    I am trying to bind FX UI controls to properties of a Hibernate Domain object. Is there any good example to refer to for this purpose?
    Thanks & Regards,
    Nitin Gupta

    Assuming you do not formulate your hibernate objects as pojos with javafx properties directly, if the hibernate object is a pojo with or without PCL, you can convert the properties of the pojo to observable values (or properties) directly. These are used in a bind statement.
    Check out what jgoodies does with BeanAdapter or PresentationModel. You need the same concept. I've attached a class that does this for a pojo already (its an incomplete port of jgoodies PresentationModel). It will work for any pojo. It does not have setter support as it was just a demonstration. Its efficient for a pojo with a large number of properties. You could also write a very short property connector to produce one observable value per property. The value of the class below is to be able to swap out the bean being observed without having to change or reset the property observable values each time. Bind once and then just reset the bean (think master detail).
    package scenegraphdemo;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.lang.reflect.Method;
    import java.util.HashMap;
    import java.util.Map;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.ObjectPropertyBase;
    import javafx.beans.property.Property;
    import javafx.beans.property.StringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.beans.value.WritableValue;
    * An object binding object that creates object bindings based on property names
    * specified as strings. This is a convenience class to avoid having observable
    * values directly dependent on the underlying bean. The actual bean the
    * properties connect can be changed dynamically using the channel or
    * <code>setBean</code>. This allows you to setup binding when you don't have
    * the bean to bind to or the bean to bind to will change as in the detail part
    * of a master-detail screen. Generally, the return values from
    * <code>getProperty()</code> should be used for binding not the factory itself.
    * The object should be a domain object bean with bean methods to get or set the
    * value using java bean naming conventions OR it should use javafx property
    * definition conventions. The factory will automatically listen for standard
    * java bean changes using <code>PropertyChangeListener</code> approaches unless
    * you indicate to not to.
    * <p>
    * When the bean itself changes, the properties fire to indicate that their
    * values may have changed and the observing object should update itself. This
    * object allows you to integrate your javafx/POJOs into the binding
    * infrastructure without being dependent on the actual underlying bean. If you
    * are familiar with jgoodies <code>BindingAdapter</code> this is a similar
    * class.
    * <p>
    * This only handles reading bean properties. Need to add set() logic.
    * <p>
    * TODO: Make this work better. Many corner cases to cover.
    * <p>
    * TODO: Instead of just method calls on POJOs, also check for PCL. Note that
    * javafx properties won't work easily they are always tied to the underlying
    * object so I would have to write another CaptiveObjectProperty object that is
    * essentially a delegator.
    public class BeanPropertyFactory<T> extends ObjectProperty<T> {
         ObservableValue<T> channel;
         Map<String, CaptiveObjectProperty> properties = new HashMap<String, CaptiveObjectProperty>();
         boolean listenForBeanPCLEvents = true;
         public boolean isListenForBeanPCLEvents() {
              return listenForBeanPCLEvents;
         public void setListenForBeanPCLEvents(boolean listenForBeanPCLEvents) {
              this.listenForBeanPCLEvents = listenForBeanPCLEvents;
              if (getBean() != null)
                   removeBeanPCLListener(getBean());
          * The bean channel where the bean is obtained.
          * @return
         public ObservableValue<T> getChannel() {
              return channel;
         public BeanPropertyFactory() {
              setChannel(new ObjectProperty());
         public BeanPropertyFactory(ObservableValue<T> channel) {
              if (channel == null)
                   setChannel(new ObjectProperty());
              else
                   setChannel(channel);
         protected void setChannel(ObservableValue<T> channel) {
              if (this.channel != null) {
                   removeBeanChangeListener(this.channel);
              this.channel = channel;
              if (this.channel != null) {
                   addBeanChangeListener(this.channel);
                   updateStringProperty(getBean());
              invalidateProperties();
              fireValueChangedEvent();
         protected StringProperty stringProperty = new StringProperty();
          * The string property is an observable toString property. It cannot be set.
          * @return
         public StringProperty beanStringProperty() {
              return stringProperty;
         public String getBeanString() {
              return beanStringProperty().getValue();
          * A listener that listens to changes in the bean channel. This only fires
          * when the bean changes not when the properties on the bean change. The
          * default actions updates the "string" property representation of this
          * object as well as attaches property change listeners.
          * @author Mr. Java
         protected class BeanChangeListener implements ChangeListener {
              @Override
              public void changed(ObservableValue arg0, Object arg1, Object arg2) {
                   if (arg1 != null) {
                        BeanPropertyFactory.this.removeBeanPCLListener(arg1);
                   if (arg2 != null) {
                        BeanPropertyFactory.this.addBeanPCLListener(arg2);
                   updateStringProperty(arg2);
         protected void updateStringProperty(Object obj) {
              if (obj != null)
                   beanStringProperty().setValue(obj.toString());
              else
                   beanStringProperty().setValue("null");
         protected void removeBeanChangeListener(ObservableValue<T> obj) {
              if (beanChangeListener == null)
                   beanChangeListener = createBeanChangeListener();
              if (obj != null) {
                   obj.addListener(beanChangeListener);
         protected void addBeanChangeListener(ObservableValue<T> obj) {
              if (beanChangeListener == null)
                   beanChangeListener = createBeanChangeListener();
              if (obj != null)
                   obj.removeListener(beanChangeListener);
          * The instance of a change listener for detecting when the bean in the bean
          * channel changes.
         ChangeListener beanChangeListener = new BeanChangeListener();
          * Subclass can override to create their bean change listener.
          * @return
         protected ChangeListener createBeanChangeListener() {
              return new BeanChangeListener();
         public BeanPropertyFactory(T bean) {
              setChannel(new ObjectProperty(bean));
         public Property getProperty(String property) {
              if (property == null || property.isEmpty())
                   throw new IllegalArgumentException("Property cannot be null");
              if (properties.containsKey(property))
                   return properties.get(property);
              CaptiveObjectProperty p = new CaptiveObjectProperty(this, property);
              properties.put(property, p);
              return p;
         @Override
         public T getValue() {
              return getBean();
          * A listener that listens for property change events on the bean. When the
          * bean changes, the listener must be removed then attached to the new bean
          * but can use the same instance of this class. The action is to inform any
          * existing property objects that the property has changed. The detection of
          * property changes is centralized in the factory class for efficiency.
         protected class BeanPropertyListener implements PropertyChangeListener {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                   if (properties.containsKey(evt.getPropertyName())) {
                        CaptiveObjectProperty p = properties.get(evt.getPropertyName());
                        p.propertyChanged();
                   updateStringProperty(getBean());
          * The cached listener instance to listen to the bean (in the bean channel)
          * property change events if it supports PCL.
         PropertyChangeListener beanPropertyListener;
          * Subclasses can override to implement their own behavior. Its best to
          * extend from <code>BeanPropertyListiner</code> to include the default
          * behavior.
          * @return
         protected PropertyChangeListener createBeanPropertyListener() {
              return new BeanPropertyListener();
          * Add a listener only if the PCL methods exist. This listens for property
          * changes on the bean's property not changes in the actually bean held by
          * the bean channel.
         protected void addBeanPCLListener(Object obj) {
              if (!isListenForBeanPCLEvents())
                   return;
              if (obj != null) {
                   if (BeanPropertyUtils.hasPCL(obj.getClass())) {
                        if (beanPropertyListener == null)
                             beanPropertyListener = createBeanPropertyListener();
                        BeanPropertyUtils.addPCL(obj, beanPropertyListener, null);
          * Remove a listener only if the PCL methods exist.
          * @see #attachBeanPCLListener
         protected void removeBeanPCLListener(Object obj) {
              if (obj != null) {
                   if (BeanPropertyUtils.hasPCL(obj.getClass())) {
                        if (beanPropertyListener == null)
                             beanPropertyListener = createBeanPropertyListener();
                        BeanPropertyUtils.removePCL(obj, beanPropertyListener, null);
          * Invalidate the properties in the property cache. Then changed the bean in
          * the bean channel. Then fire a value changed event.
          * @param bean
         public void setBean(T bean) {
              invalidateProperties();
              if (getChannel() instanceof WritableValue) {
                   ((WritableValue) getChannel()).setValue(bean);
              } else {
                   throw new IllegalArgumentException(
                             "Could not set bean value into a non-writable bean channel");
              fireValueChangedEvent();
          * Called to indicate that the underlying bean changed.
         protected void invalidateProperties() {
              for (CaptiveObjectProperty p : properties.values()) {
                   p.invalidate();
         public T getBean() {
              return getChannel().getValue();
          * Lazily get the method representing the property prior to getting or
          * setting. Because this is a property, it can also be bound to.
          * @author Mr. Java
          * @param <T>
         protected static class CaptiveObjectProperty<T> extends
                   ObjectPropertyBase<T> {
               * The string name of the property.
              String readPropertyName, writePropertyName;
               * If the property is really a javafx property, it is stored here.
              Property<T> enhancedProperty;
               * Used if the property is not an enhanced property.
              Method readMethod, writeMethod;
               * The factory that holds the bean we obtain values against.
              BeanPropertyFactory factory;
              public CaptiveObjectProperty(BeanPropertyFactory factory,
                        String property) {
                   this.readPropertyName = property;
                   this.factory = factory;
              public CaptiveObjectProperty(BeanPropertyFactory factory,
                        String property, String writePropertyName) {
                   this.readPropertyName = property;
                   this.writePropertyName = writePropertyName;
                   this.factory = factory;
              @Override
              public Object getBean() {
                   if (factory == null || factory.getBean() == null)
                        return null;
                   return factory.getBean();
              @Override
              public void store(T value) {
                   if (writeMethod == null && enhancedProperty == null) {
                        getWriteMethod(value.getClass());
                   if (writeMethod == null && enhancedProperty == null) {
                        return;
                   try {
                        if (enhancedProperty != null) {
                             enhancedProperty.setValue(value);
                             return;
                        if (getBean() == null)
                             return;
                        writeMethod.invoke(getBean(), value);
                        return;
                   } catch (Exception e) {
                        e.printStackTrace();
              @Override
              public T getValue() {
                   if (readMethod == null && enhancedProperty == null) {
                        getReadMethod();
                   if (readMethod == null && enhancedProperty == null)
                        return null;
                   try {
                        if (enhancedProperty != null)
                             return enhancedProperty.getValue();
                        if (factory.getBean() == null)
                             return null;
                        Object rval = readMethod.invoke(getBean());
                        return (T) rval;
                   } catch (Exception e) {
                        e.printStackTrace();
                   return null;
              @Override
              public String getName() {
                   return readPropertyName;
               * Invalidate the method. Perhaps the bean changed to another object and
               * we should find the method on the new object. This is called prior to
               * the <code>getBean()</code> being changed.
              public void invalidate() {
                   readMethod = null;
                   fireValueChangedEvent();
               * This is used to externally signal that the property has changed. It
               * is quite possible that this object does not detect those changes and
               * hence, an external object (in all cases the BeanPropertyFactory) will
               * signal when a change occurs. Property change detection is centralized
               * in the factory for efficiency reasons.
              public void propertyChanged() {
                   fireValueChangedEvent();
              protected Property getJavaFXReadProperty(String propertyName) {
                   if (factory.getBean() == null)
                        return null;
                   String methodName = getName() + "Property";
                   try {
                        Method mtmp = factory.getBean().getClass()
                                  .getMethod(methodName, new Class<?>[0]);
                        enhancedProperty = (Property) mtmp.invoke(factory.getBean(),
                                  new Object[0]);
                        return enhancedProperty;
                   } catch (Exception e) {
                        // e.printStackTrace();
                        // silently fail here
                   return null;
              protected void getWriteMethod(Class<?> argType) {
                   if (factory == null || factory.getBean() == null)
                        return;
                   if (enhancedProperty == null)
                        enhancedProperty = getJavaFXReadProperty(getName());
                   if (enhancedProperty != null)
                        return;
                   writeMethod = getPojoWriteMethod(getName(), argType);
               * Sets the method, either an enhanced property or the POJO method via
               * reflection.
               * @return
              protected void getReadMethod() {
                   if (factory == null || factory.getBean() == null)
                        return;
                   enhancedProperty = getJavaFXReadProperty(getName());
                   if (enhancedProperty != null)
                        return;
                   // Look for standard pojo method.
                   readMethod = getPOJOReadMethod(getName());
               * Return a get method using reflection.
               * @param propertyName
               * @return
              protected Method getPOJOReadMethod(String propertyName) {
                   if (factory.getBean() == null)
                        return null;
                   // Look for standard pojo method.
                   String methodName = getGetMethodName();
                   try {
                        Method mtmp = factory.getBean().getClass()
                                  .getMethod(methodName, new Class<?>[0]);
                        return mtmp;
                   } catch (Exception e) {
                        // silently fail here
                        // e.printStackTrace();
                   return null;
              protected String getGetMethodName() {
                   String methodName = "get"
                             + Character.toUpperCase(getName().charAt(0));
                   if (getName().length() > 1)
                        methodName += getName().substring(1);
                   return methodName;
               * Return a set method using reflection.
               * @param propertyName
               * @param argType
               * @return
              protected Method getPojoWriteMethod(String propertyName,
                        Class<?> argType) {
                   if (factory.getBean() == null)
                        return null;
                   String methodName = getSetMethodName();
                   try {
                        Method mtmp = factory.getBean().getClass()
                                  .getMethod(methodName, argType);
                        return mtmp;
                   } catch (Exception e) {
                        // silently fail here
                        // e.printStackTrace();
                   return null;
              protected String getSetMethodName() {
                   String methodName = "set"
                             + Character.toUpperCase(getName().charAt(0));
                   if (getName().length() > 1)
                        methodName += getName().substring(1);
                   return methodName;
          * Obtain a property using the binding path. The binding path should be
          * simple property names separated by a dot. The bean has to specified
          * because the return value is a property that can be used directly for
          * binding. The first property specified in the binding path should be a
          * property on the bean.
          * <p>
          * The difference between this and <code>Bindings.select()</code> is not
          * much other that it uses the bean factory machinery and the path can be
          * specified as a string. Of course, the bean can be a plain pojo.
          * @param bindingPath
          * @return
         public static Property propertyFromBindingPath(Object bean,
                   String bindingPath) {
              if (bindingPath == null || bindingPath.isEmpty())
                   return null;
              BeanPropertyFactory lastFactory = null;
              Property lastProperty = null;
              String[] parts = bindingPath.split("\\.");
              if (parts.length > 0) {
                   for (int i = 0; i < parts.length; i++) {
                        if (parts.length() <= 0 || parts[i].isEmpty()) {
                             throw new IllegalArgumentException("Binding path part " + i
                                       + " has no length");
                        BeanPropertyFactory newFactory;
                        if (i == 0)
                             newFactory = new BeanPropertyFactory(bean);
                        else
                             newFactory = new BeanPropertyFactory(
                                       (WritableValue) lastProperty);
                        lastProperty = newFactory.getProperty(parts[i].trim());
                        lastFactory = newFactory;
              return lastProperty;
         * Alot like <code>Bindings.select</code> but also handles pojos.
         * @param bean
         * @param path
         * @return
         public static Property propertyFromBindingPath(Object bean, String... path) {
              String tmp = "";
              for (int i = 0; i < path.length; i++) {
                   tmp += path[i];
                   if (i <= path.length - 1)
                        tmp += ".";
              return propertyFromBindingPath(bean, tmp);
    and a supporting classpackage scenegraphdemo;
    import java.beans.PropertyChangeListener;
    * Static methods for manipulating PCL for standard java beans.
    * @author Mr. Java
    public class BeanPropertyUtils {
         protected final static Class<?>[] NO_ARGS = new Class<?>[] { PropertyChangeListener.class };
         protected final static Class<?>[] ARGS = new Class<?>[] { String.class,
                   PropertyChangeListener.class };
         protected final static String pclAddMethodName = "addPropertyChangeListener";
         protected final static String pclRemoveMethodName = "removePropertyChangeListener";
         * Return true if the class has PCL methods. Does not check for remove.
         * <p>
         * addPropertyChangeListener(PropertyChangeListener)
         * <p>
         * addPropertyChangeListener(String, PropertyChangeListener)
         * @param bean
         * @return
         public static boolean hasPCL(Class<?> clazz) {
              try {
                   if (clazz.getMethod(pclAddMethodName, NO_ARGS) != null) {
                        return true;
              } catch (Exception e) {
                   // silently fail
              try {
                   if (clazz.getMethod(pclAddMethodName, ARGS) != null) {
                        return true;
              } catch (Exception e) {
                   // silently fail
              return false;
         * Add a listener.
         * @param bean
         * @param listener
         * @param propertyName
         public static void addPCL(Object bean, PropertyChangeListener listener,
                   String propertyName) {
              try {
                   if (propertyName == null) {
                        bean.getClass().getMethod(pclAddMethodName, NO_ARGS)
                                  .invoke(bean, new Object[] { listener });
                   } else {
                        bean.getClass()
                                  .getMethod(pclAddMethodName, ARGS)
                                  .invoke(bean,
                                            new Object[] { propertyName, listener });
              } catch (Exception e) {
                   e.printStackTrace();
         * Remove a listener.
         * @param bean
         * @param listener
         * @param propertyName
         public static void removePCL(Object bean, PropertyChangeListener listener,
                   String propertyName) {
              try {
                   if (propertyName == null) {
                        bean.getClass().getMethod(pclRemoveMethodName, NO_ARGS)
                                  .invoke(bean, new Object[] { listener });
                   } else {
                        bean.getClass()
                                  .getMethod(pclRemoveMethodName, ARGS)
                                  .invoke(bean,
                                            new Object[] { propertyName, listener });
              } catch (Exception e) {
                   e.printStackTrace();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

  • Choicebox with Domain-Objects

    Hi,
    I'm struggeling to find out how to deal with ChoiceBox and domain objects whose toString-method is not appropriate for the label. For ListView I'm able to set a cell factory where I was able to customize the domain to string translation but I'm unable to find something similar for ChoiceBox.
    Tom

    Guess what I've done [1] ;-)
    [1]https://github.com/tomsontom/emfdatabinding-tutorial/blob/master/org.eclipse.ufacekit.ui.jfx.databinding/src/org/eclipse/ufacekit/ui/jfx/databinding/controls/ChoiceBoxViewer.java

  • Gradient Annotator across multiple objects - weirdness

    I have six rectangles in a row. I apply a radial gradient to them as a whole, by dragging the Gradient Tool. According to the documentation for CS4, that's what you do if you want only one Gradient Annotator across multiple objects. Problem is, I can see the Annotator, but not the color stops. If I deselect all, and select only one rectangle, I can see and move the stops, but it only effects the selected shape. Further, if I group the objects, the Annotator doesn't appear at all, and when I UNgroup, I get six Annotators.
    None of these examples behave as I think they should. Yes, I have "Show Gradient Annotator" on in the View menu. I've worked with the Annotator a fair amount, but it's always seemed buggy.
    What I want to do is apply the gradient across multiple objects, as in example 1, then edit it across multiple objects. Is that so hard?

    It is still not actually one gradient and you do see actually the 
    annotator with four elements one for each object but if you change the 
    fills you can see them with the annotator which the originally says 
    they cannot see, which is true unless you hover the cursor or one of 
    the annotator you only have to change the fill in one o change them all
    in a relative manner.
    The compound path method will adjust the gradient by stretching the 
    annotator or actually the gradient and that might be desired on many 
    occasions.
    the only difference between prior versions is that you can adjust the 
    markers at the target object or group and you have more directional 
    control as well even if the annotator is a bit ugly and unwieldy.
    In order to see four annotators one seems to have either unselect the 
    object then select them again and the gradient tool or find some kind 
    of sweet spot to make them show up with the markers as you hover.
    Still no gradient that follows the path and no radar gradient.

  • Domain Object Validation Errors

    I have created a Domain object for PhoneNumber validation. Several entity attributes are defined as PhoneNumber. When validation fails for a PhoneNumber, the Domain object throws a DataCreationException with a generic error message.
    I would like to be able to catch this exception and throw a new DataCreationException with a more specific error message. Is this possible?
    I have a page where a users enter several phone numbers -- home, work, cell, etc. It would nice if the error message they see is specific to the phone number that failed.

    The mData variable in your domain class holds the value of the attribute being validated. So, in your validate() method you can throw a new DataCreationException with an error message that depends on the value of mData.
    The ADF Developer's Guide has an example of this - see example 36-2 in section 36.1.4.3.
    Blaise

Maybe you are looking for

  • Downloads in Downloads Folder error

    This doesn't relate to a Mac OS X download.... in my download folder, I can see the download bar, but it's stalled, I search through the folder and see nothing that is downloading so I'm starting to assume it's a bug in OS X 10.6 Any way to resolve t

  • My iTunes program is giving me a message that says, "Runtime error" and wont open iTunes. How do I fix this?

    My iTunes program is giving me a message that says, "Runtime error" and wont open iTunes. How do I fix this?

  • Sales order does not extract plant information from material master data

    Hi experts, I have created a sales order. However, the plant in the shipping tab can only be manually entered. I have made the check: the customer material master data does not have the plant info. the customer master data does not have it either. It

  • Reverse engineering output of a query

    The query below is able to track changes i two tables by detecting changes by colun row by row. I woul like to reengineer the query to look like the desired output. select HOUSE_KEY, LOW, HIGH, count(src1) TBL_CURRENT, count(src2) TBL_STAGE from ( se

  • Copying to RAID V Slow

    Hi, Been using this set-up for 18 months faultless, until today..... I have a rather strange problem happening with our Xserve RAID. One half of the raid is used for Live work and the other is storage, items to be archived etc..... One half of the RA