net.wgen.op
Class OpExecutorFactory

java.lang.Object
  extended bynet.wgen.op.OpExecutorFactory
Direct Known Subclasses:
DirectExecutorFactory, EjbOpExecutorFactory

public abstract class OpExecutorFactory
extends java.lang.Object

Factory to create OpExecutors so that the caller doesn't have to set them manually in each Op.

The default factory is the EjbOpExecutorFactory which produces EjbOpExecutors that lookup a JNDI-registered EJB that will process the Op.

To override this for a non-appserver context, such as within your IDE, you can either set the system property

net.wgen.data.OpExecutorFactory
with the fully-qualified class name of the alternate OpExecutorFactory, or you can manually set up your own factory and identify it to this OpExecutorFactory as the delegated-to Factory.

The following code, for example, creates a "Direct" factory which creates DirectOpExecutors who make direct connections to the database (not thru EJB). The DirectOpExecutors use the DataSource names declare in the Ops to map to actual connections.

Here is how you might setup a TestCase that would bypass EJB.

    String cxUrl = "jdbc:oracle:thin:@howl.wgenhq.net:1521:DEV2";
    DirectExecutorFactory fact = new DirectExecutorFactory();
    fact.mapConnectionFactory( SeeApplication.DATA_SOURCE, cxUrl , "walk" , "walk123" );
    fact.mapConnectionFactory( AMPApplication.DATA_SOURCE, cxUrl , "wgen" , "wgen123" );
    OpExecutorFactory.setDelegatingFactory( fact );
 

Version:
$Id: OpExecutorFactory.html,v 1.2 2007/01/28 04:09:36 paulfeuer Exp $
Author:
Paul Feuer, Wireless Generation, Inc.
See Also:
EjbOpExecutorFactory, DirectExecutorFactory

Field Summary
private static OpExecutorFactory _delegatingFactory
          The concrete factory that will produce the OpExecutorFactory.
static java.lang.String SYSTEM_PROPERTY
          The name of the system property in which to find a fully-qualified class name of an implementation of OpExecutorFactory.
 
Constructor Summary
OpExecutorFactory()
           
 
Method Summary
protected abstract  OpExecutor _createExecutorForOp(Op op)
          Internal create to be implemented by the _delegatingFactory.
static OpExecutor create(Op op)
          Invoked by the Op to provide it an OpExecutor.
static OpExecutorFactory getDelegatingFactory()
          The current _delegatingFactory used to create OpExecutors.
private static void initializeFromSystemProperty()
          Examines the system property for a fully-qualified class name identifying an implementation of an OpExecutorFactory, or defaults to an EjbOpExecutor.
static void setDelegatingFactory(OpExecutorFactory delegatingFactory)
          Allow a runtime override of the _delegatingFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_PROPERTY

public static final java.lang.String SYSTEM_PROPERTY
The name of the system property in which to find a fully-qualified class name of an implementation of OpExecutorFactory. The static value is "net.wgen.op.OpExecutorFactory".


_delegatingFactory

private static OpExecutorFactory _delegatingFactory
The concrete factory that will produce the OpExecutorFactory.

Constructor Detail

OpExecutorFactory

public OpExecutorFactory()
Method Detail

initializeFromSystemProperty

private static void initializeFromSystemProperty()
Examines the system property for a fully-qualified class name identifying an implementation of an OpExecutorFactory, or defaults to an EjbOpExecutor.

See Also:
SYSTEM_PROPERTY

_createExecutorForOp

protected abstract OpExecutor _createExecutorForOp(Op op)
Internal create to be implemented by the _delegatingFactory.

Parameters:
op - the Op requesting the OpExecutor
Returns:
an OpExecutor

create

public static OpExecutor create(Op op)
Invoked by the Op to provide it an OpExecutor.

Parameters:
op - the Op requesting the OpExecutor
Returns:
an OpExecutor from the _delegatingFactory
See Also:
Op.execute()

setDelegatingFactory

public static void setDelegatingFactory(OpExecutorFactory delegatingFactory)
Allow a runtime override of the _delegatingFactory.

Parameters:
delegatingFactory - the new factory that will provide the OpExecutors

getDelegatingFactory

public static OpExecutorFactory getDelegatingFactory()
The current _delegatingFactory used to create OpExecutors.