0

How can I configure Java Melody with JPA configured in Spring but not using a persistence.xml file. Note: I am specifically using eclipselink. The java melody instructions only show configuring with a persistence.xml file: https://code.google.com/p/javamelody/wiki/UserGuideAdvanced#JPA_monitoring

Ben Green
  • 3,953
  • 3
  • 29
  • 49
Travis Schneeberger
  • 2,010
  • 20
  • 23

1 Answers1

1

If you are using Spring with the JpaVendorAdapter abstraction you can create your own Java Melody enabled Vendor Adapter. Here is an example of one I created for eclipselink. Note: this shows that java melody can be configured without using a persistence.xml file.

/**
 * This is a copy of the 
 * {@link org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter} 
 * but using the Java Melody PersistenceProvider.
 */
public class MonitoringEclipseLinkJpaVendorAdapter 
        extends AbstractJpaVendorAdapter {
    private final PersistenceProvider persistenceProvider;
    try {
        persistenceProvider = (PersistenceProvider) 
            Class.forName("net.bull.javamelody.JpaPersistence").newInstance();
    } catch(ClassNotFoundException|InstantiationException|
            IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    //...snip - the rest is the same as the EclipseLinkJpaVendorAdapter class...
}
bunyaCloven
  • 313
  • 1
  • 4
  • 14
Travis Schneeberger
  • 2,010
  • 20
  • 23