Difference between revisions of "EclipseLink/Examples/DBWS/DBWSIntermediateCustomizer"

From Eclipsepedia

Jump to: navigation, search
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 +
<css>
 +
  .source-java5 {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-xml {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-text {padding:4px;border:1px solid black; background-color: white;}
 +
</css>
 +
__NOTOC__
 
===EclipseLink Session Customization===
 
===EclipseLink Session Customization===
 
The primary reason to use an EclipseLink <tt>SessionCustomizer</tt> is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.
 
The primary reason to use an EclipseLink <tt>SessionCustomizer</tt> is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.
  
 
The following example shows how to implement a <code>o.e.p.config.SessionCustomizer</code>:
 
The following example shows how to implement a <code>o.e.p.config.SessionCustomizer</code>:
<css>
 
  .source-java5 {border-style: solid; background-color: white;}
 
</css>
 
 
<source lang="java5">
 
<source lang="java5">
 
package some.java.package;
 
package some.java.package;
Line 27: Line 30:
  
 
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:
 
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:
<css>
 
  .source-xml {border-style: solid; background-color: white;}
 
</css>
 
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  

Latest revision as of 10:08, 7 October 2010


[edit] EclipseLink Session Customization

The primary reason to use an EclipseLink SessionCustomizer is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.

The following example shows how to implement a o.e.p.config.SessionCustomizer:

package some.java.package;
 
import org.eclipse.persistence.config.SessionCustomizer; 
import org.eclipse.persistence.sessions.Session; 
import org.eclipse.persistence.sessions.DatabaseLogin; 
 
public class MySessionCustomizer implements SessionCustomizer {
 
  public MySessionCustomizer() {
  }
 
  public void customize(Sesssion session) { 
    DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();
    // enable 'dirty' reads
    login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED); 
  } 
}

In the DBWSBuilder builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:

<?xml version="1.0" encoding="UTF-8"?> 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <properties>
    <property name="projectName">customize_test</property>
     ...
    <property name="orSessionCustomizerClassName">some.java.package.MyORSessionCustomizer</property>

or

<?xml version="1.0" encoding="UTF-8"?> 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <properties>
    <property name="projectName">customize_test</property>
     ...
    <property name="oxSessionCustomizerClassName">some.java.package.MyOXSessionCustomizer</property>


For details, see Session Customization.