Class XRServiceFactory

java.lang.Object
org.eclipse.persistence.internal.xr.XRServiceFactory
Direct Known Subclasses:
ProviderHelper

public class XRServiceFactory extends Object

INTERNAL: helper class that knows how to build a XRServiceAdapter (a.k.a DBWS). An XRService requires the following resources:

  • metadata in the form of a descriptor file called eclipselink-dbws.xml
  • an XML Schema Definition (.xsd) file called eclipselink-dbws-schema.xsd
  • a TopLink sessions.xml file called eclipselink-dbws-sessions.xml
      the naming convention for the sessions.xml files can be overriden by the optional <sessions-file> entry in the eclipselink-dbws.xml descriptor file.
  • EclipseLink metadata in the form of a EclipseLink Project (either deployment XML or Java classes).

    A typical XRService requires two projects: one to represent the O-R side, the other to represent the O-X side.
    The O-R and O-X Projects metadata must have:
    i) identical case-sensitive Project names:

     <?xml version="1.0" encoding="UTF-8"?>
     <eclipselink:object-persistence version="Eclipse Persistence Services ..."
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:eclipselink="http://xmlns.oracle.com/ias/xsds/eclipselink"
       >
       <eclipselink:name>example</eclipselink:name>
     or
     ...
     import org.eclipse.persistence.sessions.Project;
     public class SomeORProject extends Project {
       public SomeORProject () {
         setName("Example");
         ...
     }
     public class SomeOXProject extends Project {
       public SomeOXProject () {
         setName("Example");
         ...
     }
     
    ii) identical case-sensitive aliases for Descriptors that are common between the projects:
     <eclipselink:class-mapping-descriptor xsi:type="eclipselink:relational-class-mapping-descriptor">
       <eclipselink:class>some.package.SomeClass</eclipselink:class>
       <eclipselink:alias>SomeAlias</eclipselink:alias>
     ...
     <eclipselink:class-mapping-descriptor xsi:type="eclipselink:xml-class-mapping-descriptor">
       <eclipselink:class>some.package.SomeClass</eclipselink:class>
       <eclipselink:alias>SomeAlias</eclipselink:alias>
     
An example eclipselink-dbws.xml descriptor file:
 <?xml version="1.0" encoding="UTF-8"?>
 <dbws
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   >
   <name>example</name>
   <sessions-file>example-dbws-sessions.xml</sessions-file>
   <query>
     <name>countEmployees</name>
     <result>
       <type>xsd:int</type>
       <simple-xml-format>
         <simple-xml-format-tag>employee-info</simple-xml-format-tag>
         <simple-xml-tag>aggregate-info</simple-xml-tag>
       </simple-xml-format>
     </result>
     <sql><![CDATA[select count(*) from EMP]]></sql>
   </query>
   <query>
     <name>findAllEmployees</name>
     <result isCollection="true">
       <type>empType</type>
     </result>
     <sql><![CDATA[select * from EMP]]></sql>
   </query>
 </dbws>
 
  • Field Details

  • Constructor Details

    • XRServiceFactory

      public XRServiceFactory()
  • Method Details

    • buildService

      public XRServiceAdapter buildService()
    • buildService

      public XRServiceAdapter buildService(XRServiceModel xrServiceModel)
    • initializeService

      public void initializeService(ClassLoader parentClassLoader, InputStream xrSchemaStream)

      INTERNAL: Initialize the various components (of the XRService} (O-R Project, O-X Project, Schema definitions, auto-generated classes, etc.)

      Parameters:
      parentClassLoader - the parent ClassLoader for the auto-generated classes.
      xrSchemaStream - stream resource for the XRService's .xsd file.
    • customizeSession

      public void customizeSession(Session orSession, Session oxSession)
    • loadXMLSchema

      public void loadXMLSchema(InputStream xrSchemaStream)

      INTERNAL: Read and unmarshal XRService's .xsd file.

      Parameters:
      xrSchemaStream - Stream resource for the XRService's .xsd file.
    • loadORMetadata

      protected Project loadORMetadata(XRDynamicClassLoader xrdecl, ServerSession session)

      INTERNAL: Create a Project using ORM metadata. The given classloader is expected to successfully load 'META-INF/eclipselink-dbws-or.xml'.

      Parameters:
      xrdecl - ClassLoader used to search for eclipselink-dbws-or.xml.
      session - ORM session.
    • loadOXMetadata

      protected Project loadOXMetadata(ClassLoader xrdecl, Session session)

      INTERNAL: Create a Project using OXM metadata. The given classloader is expected to successfully load 'META-INF/eclipselink-dbws-ox.xml'.

      Parameters:
      xrdecl - ClassLoader used to search for eclipselink-dbws-ox.xml.
      session - OXM session (only for logging).
    • prepareDescriptors

      protected static void prepareDescriptors(Project oxProject, Project orProject, XRDynamicClassLoader xrdcl)

      INTERNAL: Perform any post-load descriptor modifications, such as altering attribute classification on a given mapping, or converting class names to classes. In addition, JAXB and JPA Embeddables will have the descriptor alias set to the class name (w/o package), which will contain an upper case first character, meaning that the OR/OX descriptors will have to be aligned in some cases.

    • getDescriptorForClassName

      protected static ClassDescriptor getDescriptorForClassName(Project project, String javaClassName)
      Returns a ClassDescriptor from the given project with the matching javaClassName, or null if not found.
    • buildSessions

      public void buildSessions()

      INTERNAL:

    • loginSessions

      public void loginSessions()

      INTERNAL:

    • buildDescriptorIndex

      public void buildDescriptorIndex()

      INTERNAL:

    • validateOperations

      public void validateOperations()

      INTERNAL:

    • initializeOperations

      public void initializeOperations()

      INTERNAL:

    • logoutSessions

      protected void logoutSessions()

      INTERNAL:

    • resolveName

      protected QName resolveName(String name, NamespaceResolver ns)

      INTERNAL:

    • getDocumentBuilder

      public static DocumentBuilder getDocumentBuilder()
    • getTransformer

      public static Transformer getTransformer()
    • updateFindQueryNames

      protected static void updateFindQueryNames(Project orProject)

      INTERNAL: Legacy projects have 'findAll' and 'findByPrimaryKey' queries, whereas we now expect these to have the descriptor alias appended (preceded with underscore), + 'Type'. For example, if we have an Employee descriptor, the find queries would be: 'findAll_employeeType' and 'findByPrimaryKey_employeeType'.