|
IBM WebSphere Application ServerTM Release 7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.websphere.sdo.mediator.ejb.MediatorFactory
public class MediatorFactory
The factory class used for creating an instance of Mediator
.
An EJB Mediator is an extension of the J2EE EJB programming model that allows an ejb query
to return a DataGraph and to perform updates based on graph's change log.
The EJB Mediator takes as an argument an array of EJB query statements. Each query defines an DataObject type. The SELECT clause lists the cmp fields or expressions to return into the data object. The dataypes supported are
java primitive and wrapper types String, BigDecimal, BigInteger, byte[] java.sql.Date, Time and Timestamp java.util.Date, Calendar
The WHERE clause specifies the filtering conditions.
The first query in the array specifies either an EJB abstract schema name or a query parameter that designates a collection of EJBs.
The FROM clause of the other queries specifies an ejb relationship which is used to navigate to the related schema and to create DataObject references. The relationship may be single or many valued. The query statements must form a hierarchy of schema types and a schema can be referenced in one and only one query FROM clause.
Each FROM clause can only specify one element. Joins are not allowed.
In order to the DataObject to be updateable, the query must retrieve all the primary fields of the EJB and if the EJB is defined with one or more optimistic predicate fields, at least one of these fields must be retrieved. It is the caller's responsibility to ensure that the optimistic predicate field is incremented or updated appropriately. DataObject attributes derived from a query expression such as e.salary+e.bonus as total_pay or e.dept.name as deptName or a method call are not updateable.
Aggregate expressions (e.g. SUM, AVG, COUNT ) can be used in subselects.
The following compound ejb query is valid
select d.deptno from Dept as d select e.empid from in(d.emps) as e
The following query is invalid
select d.deptno from Dept as d select p.projno from in(e.projects) as p select e.empid from in(d.emps) as e
because the correlation id "e" in the second query has not been defined.
Collection valued input argument allowed in FROM clause. If ?1 refers to a collection of Dept EJBs then the following query is valid
select d.deptno from (Dept)?1 as d
This example shows multiple paths in the type hierarchy.
The parms passed on the create call are used during query execution, unless getGraph call supplies another set of input parameters. In that case parameters passed in getGraph call are used. However the type of the input parameters passed during the getGraph call need to be the same as the ones passed during the create mediator call.String[] query = { "select d.deptno, d.name from Dept as d where d.deptno between ?1 and ?2 ", "select e.empid,e.name,e.salary+e.bonus as totalPay from in(d.emps)as e", "select p.projid from in(d.projects) as p ", "select t.taskid, t.cost from in(p.tasks)as t where t.cost > ?3" }; Object[] parms = new Object{ new Integer(40), new Integer(50), new Double(60.0) }; Object[] realParms = new Object{ new Integer(70), new Integer(80), new Double(90.0) }; Mediator m = MediatorFactory.getInstance().createMediator( query, parms); DataObject root = m.getGraph(realParms); // update the DataGraph and then ... m.applyChanges(root);
The mediator can return dynamic DataObjects or an EClass argument can be specified for a user defined DataObject schema. The user defined DataObject schema must have class names corresponding to EJB abstract schema names or a map argument can be used to specify the mapping between EJB ASN names and unqualified EClass names.
The mediator supports three patterns of DataObject containment.
The ROOT_CONTAINS_ALL pattern is a pattern in which a dummy graph root object contains all other EJB related DataObjects. EJB relationships map to noncontainment references between DataObjects.
For user defined graph schema a pattern of NO_DUMMY_ROOT requires that the first EJB query return a single result and all DataObject other than the graph root are contained by the EJB relationship specifed the query FROM clause.
ROOT_CONTAIN_SOME pattern is a hybrid pattern in which a dummy graph root object exists and each DataObject is contained either by the dummy root or the EJB relationship specified in the query.
If the user specified schema contains properties that are not retrieved by the query, the properties will be unset.
All factory and mediator methods must be invoked in the context of either a user transaction or a container transaction.
Field Summary | |
---|---|
static int |
NO_DUMMY_ROOT
There is no dummy root DataObject. |
static int |
ROOT_CONTAINS_ALL
There is a dummy root DataObject that contains all other DataObjects. |
static int |
ROOT_CONTAINS_SOME
There is a dummy root DataObject. |
Method Summary | |
---|---|
Mediator |
createMediator(java.lang.String[] ejbQuery,
java.lang.Object[] parms)
Creates an ejb mediator using an array EJB query statements. |
Mediator |
createMediator(java.lang.String[] ejbQuery,
java.lang.Object[] parms,
org.eclipse.emf.ecore.EClass schema)
Creates an ejb mediator from an array of EJB query statements. |
Mediator |
createMediator(java.lang.String[] ejbQuery,
java.lang.Object[] parms,
org.eclipse.emf.ecore.EClass schema,
java.util.Map asnToSDONameMap,
int pattern)
Creates an ejb mediator from an array of EJB query statements. |
static MediatorFactory |
getInstance()
Obtain the factory class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ROOT_CONTAINS_ALL
public static final int ROOT_CONTAINS_SOME
public static final int NO_DUMMY_ROOT
Method Detail |
---|
public Mediator createMediator(java.lang.String[] ejbQuery, java.lang.Object[] parms) throws QueryException
ejbQuery
- The array of ejb query statements.parms
- Values for query input arguments.
QueryException
- Invalid query. Message contains details.public Mediator createMediator(java.lang.String[] ejbQuery, java.lang.Object[] parms, org.eclipse.emf.ecore.EClass schema) throws QueryException
ejbQuery
- The array of EJB query statements.parms
- Values for query input arguments.schema
- Provides the EMF schema class of the root DataObject.
QueryException
- Invalid query. Message contains details.public Mediator createMediator(java.lang.String[] ejbQuery, java.lang.Object[] parms, org.eclipse.emf.ecore.EClass schema, java.util.Map asnToSDONameMap, int pattern) throws QueryException
ejbQuery
- Array of EJB query statements.parms
- Values for query input arguments.schema
- Provides the EMF schema class of the root DataObject.asnTOSDONameMap
- The map between the EJB asn name and the unqualifed EClass class name.pattern
- DataObject containment pattern specifid by ROOT_CONTAINS_SOME, NO_DUMMY_ROOT or ROOT_CONTAINS_ALL.
QueryException
- Invalid query. Message contains details.public static MediatorFactory getInstance()
|
IBM WebSphere Application ServerTM Release 7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |