Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Support for multiple byte code enhancing products that includes EclipseLink?

Hi Doug,

Although I am not aware of anyone using EclipseLink in a system where other weaving is occurring, in theory I can see no reason why the weaving itself would be a problem.

The question of whether things would work would really come down to what is being weaved and whether the chances being made are compatible.

The main part of the class EclipseLink weaves is access to instance variables that are persistent from a JPA point of view. We basically replace GETFIELD and SETFIELD with calls to our own methods that do some extra processing.

  If you imagine the following field and methods:

---

    private Employee manager;

    public Employee getManager() {
        return manager;
    }

    public void setManager(Employee manager) {
        this.manager = manager;
    }

---

  We produce something that resembles the following:

---
   We add the field:

    protected WeavedAttributeValueHolderInterface _persistence_manager_vh;

   And change the methods to:

   public Employee getManager()
    {
        return _persistence_getmanager();
    }

    public void setManager(Employee manager)
    {
        _persistence_setmanager(manager);
    }

    And add the methods:

    public WeavedAttributeValueHolderInterface _persistence_getmanager_vh()
    {
        _persistence_initialize_manager_vh();
if(_persistence_manager_vh.isCoordinatedWithProperty() || _persistence_manager_vh.isNewlyWeavedValueHolder())
        {
            Employee employee = (Employee)getManager();
            if(employee != _persistence_manager_vh.getValue())
            {
                setManager(employee);
            }
        }
        return _persistence_manager_vh;
    }

public void _persistence_setmanager_vh(WeavedAttributeValueHolderInterface weavedattributevalueholderinterface)
    {
        _persistence_manager_vh = weavedattributevalueholderinterface;
        if(weavedattributevalueholderinterface.isInstantiated())
        {
            Employee employee = getManager();
            Object obj = weavedattributevalueholderinterface.getValue();
            if(employee != obj)
            {
                setManager((Employee)obj);
            }
        }
    }

    public Employee _persistence_getmanager()
    {
        _persistence_checkFetched("manager");
        _persistence_initialize_manager_vh();
        manager = (Employee)_persistence_manager_vh.getValue();
        return manager;
    }

   public void _persistence_setmanager(Employee employee)
    {
        _persistence_getmanager();
        manager = employee;
        _persistence_manager_vh.setValue(employee);
        return;
    }

    protected void _persistence_initialize_manager_vh()
    {
        if(_persistence_manager_vh == null)
        {
            _persistence_manager_vh = new ValueHolder(manager);
            _persistence_manager_vh.setIsNewlyWeavedValueHolder(true);
        }
    }

---

The above is an example of the weaving we do to enable LAZY Access of *ToOne relationships for Entities using PROPERTY access. There is additional weaving we do to enhance performance in other ways, but that weaving can be enabled/disabled through persistence unit properties.

If there are reasonable patterns we can follow to make weaving by other products works correctly, it is certainly something we would be interested in doing.

'Hope this provides some help,
-Tom

Gschwind, Doug wrote:
Hello everyone,

EclipseLink needs to do some form of byte code enhancement/manipulation to provide support for lazy loading of one to one and one to many relationships for example. I am wondering if multiple products can be used that also need to do some form of byte code enhancement/manipulation, in an environment in which EclipseLink also exists? E.g. I would like to use AspectJ to advise some domain model classes that are JPA mapped via EclipseLink. Thus, AspectJ would need to do some byte code enhancement as would EclipseLink.

Is it known that this kind of thing would work? Could AspectJ weave first and then have EclipseLink weave, or vice versa, and would the resulting byte code honor the weaving that the first pass of weaving produced?

Regards,

Doug Gschwind






The contents of this electronic mail message and any attachments are confidential, possibly privileged and intended
for the addressee(s) only. Only the addressee(s) may read, disseminate, retain or otherwise use this message. If
received in error, please immediately inform the sender and then delete this message without disclosing its contents
to anyone.


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top