public class PCachedContext
extends com.portal.appcenter.BRMClientContext
PCachedPortalContext
is a subclass of PortalContext
that adds data caching. The usefulness of caching Portal data is limited
and somewhat problematic, however, this class is still useful for the following
reasons:
The client side, is limited to knowledge of model handles and a string description of the field data. It doesn't need to have PCM downloaded, or have a lot of built-in knowledge of Portal. Field descriptions can therefore refer to fields in any database, and type can refer to any kind of table for other types.
A lot of data access is nested, for example, flists in flists. The Description/FieldSpec interfaces provide a common entry point to extract field values from descending flists, an operation that would otherwise have to be repeated frequently throughout the application code.
Hostname, OPFLG_ADD_ENTRY, OPFLG_CALC_ONLY, OPFLG_CHACHABLE, OPFLG_COUNT_ONLY, OPFLG_META_ONLY, OPFLG_NO_DESCEND, OPFLG_NO_RESULTS, OPFLG_READ_READPAST, OPFLG_READ_RESULT, OPFLG_READ_UNCOMMITTED, OPFLG_REV_CHECK, OPFLG_SEARCH_DB, OPFLG_SEARCH_ONE_PARTITION, OPFLG_SEARCH_PARTITIONS, OPFLG_USE_POID_GIVEN, ProgramName, TRAN_OPEN_GLOBALTRANSACTION, TRAN_OPEN_LOCK_OBJ, TRAN_OPEN_READONLY, TRAN_OPEN_READWRITE
Constructor and Description |
---|
PCachedContext()
Creates a default instance of a
PCachedContext . |
PCachedContext(PCachedContext ctx)
Creates an instance of
PCachedContext from another
PCachedContext . |
PCachedContext(PortalContext ctx)
Create a PCachedContext using an existing PortalContext
that has already been connected to Portal.
|
PCachedContext(Properties uprops)
Creates an instance of
PCachedContext , given some base
properties. |
Modifier and Type | Method and Description |
---|---|
PModelHandle |
createModelFrom(FList fl)
Creates a new model handle from an
Flist and sets that
Flist in the cache. |
PModelHandle |
createModelFrom(FList fl,
String type)
Creates a new model handle of a specified type from an
Flist ,
and sets that Flist in the cache. |
PModelHandle |
createModelFrom(Poid pd)
Creates a new model handle from a
Poid . |
PModelHandle |
createModelFrom(SparseArray sa)
Creates a new model handle from a
SparseArray . |
void |
discardModel(PModelHandle mh)
Removes a model from the cache to free resources.
|
com.portal.permission.ScopeEntryPoint |
getCachedScope()
Returns the cached scope entry point which was cached before cm timed out.
|
Object |
getField(FList list,
PDataFieldSpecification spec)
Gets a field from an
Flist model. |
Object |
getField(PModelHandle mh,
PDataFieldSpecification spec)
Gets a field from a model.
|
Object |
getModelField(FList data,
PFieldSpecification spec)
Gets a field from an
Flist model. |
Object |
getModelField(PModelHandle data,
PFieldSpecification spec)
Gets a field from a model.
|
PModelHandle |
getOrCreateModelFrom(FList fl)
Creates a model for the specified
Flist , but doesn't put
the flist in the cache unless the created model handle has no match. |
com.portal.permission.ScopeEntryPoint |
getScope()
Retrieves the current scope for this connection through an opcode
call to Portal.
|
FList |
getWholeObject(PModelHandle mh)
Force the cache to be loaded with an entire storable class for
Forces the cache to be loaded with an entire storable class for
a given model handle.
|
FList |
getWholeObject(PModelHandle mh,
boolean force)
Forces the cache to be loaded with an entire storable class for
a given model handle.
|
void |
logCache()
A debug function that dumps the cache to the log file.
|
Object |
lookupModel(PModelHandle handle)
Gets the cached model that corresponds to the supplied model handle.
|
Object |
lookupModel(PModelHandle handle,
boolean ensureWhole,
int updateFlag)
Returns the model data associated with
handle . |
Poid |
lookupPoid(PModelHandle modl)
Get the
Poid from the cache for a model handle. |
FList |
opcode(int op,
int flags,
FList in)
Sends an opcode to the server.
|
FList |
opcode(int op,
int flags,
FList in,
boolean setCacheToStale)
Overloaded method of opcode so that information can be provided whether to stale the cache or not.
|
FList |
opcode(int op,
int flags,
PModelHandle in)
Calls an opcode.
|
FList |
opcode(int op,
int flags,
PModelHandle in,
boolean setCacheToStale)
Overloaded method of opcode so that information can be provided whether to stale the cache or not.
|
void |
open(FList in)
Opens a connection context with the server.
|
PModelHandle[] |
search(int op,
FList in)
Calls the
search opcode, but returns an array of model handles. |
FList |
search(int op,
FList in,
boolean cacheResults)
Calls the search opcode and depending on cacheResults flag, it caches the results.
|
PModelHandle[] |
search(int op,
int flag,
FList in)
Calls the
search opcode, but returns an array of model handles. |
void |
setField(FList list,
PDataFieldSpecification spec,
Object val)
Sets an
Flist field in a model to the specified value. |
void |
setField(PModelHandle modl,
PDataFieldSpecification spec,
Object val)
Sets a field in a model to the specified value.
|
void |
setModel(PModelHandle modl,
FList fl)
Sets an
Flist model in the cache associated with a handle. |
void |
setModel(PModelHandle modl,
Poid pd)
Sets a
Poid model in the cache associated with a handle. |
void |
setModel(PModelHandle modl,
SparseArray sa)
Sets a
SparseArray model in the cache associated with a handle. |
void |
setScope(com.portal.permission.ScopeEntryPoint scope)
This method is used to set the scope of the connection.
|
addConnectionListner, clearThreadInfo, close, connect, connect, disconnect, enableOpcodeLogging, genCorrelationId, genCorrelationId, genCorrelationId, genCorrelationId, genCorrelationId, getContext, getContextInfoDetails, getCorrelationId, getCurrentDB, getDefaultLog, getHost, getInetAddress, getLocalAddress, getLocalPort, getPort, getReasonCode, getSession, getSocketChannelHashCode, getSocketChannelListener, getSocketChannelPort, getTransState, getUserID, getUserName, getUserProperty, initHostnameAndProgramName, isContextValid, isOpcodeLoggingEnabled, isSocketChannelConnected, isSocketChannelOpen, isSocketChannelRegistered, opcode, opcodeReceive, opcodeReceive, opcodeReceive, opcodeSend, opcodeSend, parseConnectString, reconnect, reconnectAfterUpdatePwd, recvCorrelation, removeConnectionListener, sendCorrelation, serviceSearch, setAppName, setCorrelationId, setLocalProperties, setSocketChannelListener, setTimeout, setTimeoutOverrideOriginal, transactionAbort, transactionCommit, transactionOpen, transactionOpen
public PCachedContext() throws EBufException
PCachedContext
.EBufException
- thrown if an error occurspublic PCachedContext(PortalContext ctx) throws EBufException
PortalContext
- whose connection to Portal BAS will use
internally by PCachedContext. Note that the PortalContext
is reset to its default values and is no longer connected
to Portal.EBufException
public PCachedContext(Properties uprops) throws EBufException
PCachedContext
, given some base
properties.uprops
- the base Properties
objectEBufException
- thrown if an error occurspublic PCachedContext(PCachedContext ctx) throws EBufException
PCachedContext
from another
PCachedContext
.
The two contexts share a cache, but have different Portal connections.ctx
- another PCachedContext
to copyEBufException
- thrown if an error occurspublic void setScope(com.portal.permission.ScopeEntryPoint scope)
scope,
- Passed scope will be set in the connection.public void open(FList in) throws EBufException
open
in class com.portal.appcenter.BRMClientContext
in
- an Flist
that contains login informationEBufException
- thrown if an error occurspublic com.portal.permission.ScopeEntryPoint getCachedScope()
public FList opcode(int op, int flags, FList in) throws EBufException
opcode
in class com.portal.appcenter.BRMClientContext
op
- the opcode to performflags
- the control flags for opcodein
- the opcode parameter FList
FList
.EBufException
- thrown if an error occursPortalOp
public FList opcode(int op, int flags, PModelHandle in) throws EBufException
opcode
- the opcode to callin
- the input FList
modelflags
- the opcode flagsFList
model.EBufException
- thrown for Portal errorspublic FList opcode(int op, int flags, FList in, boolean setCacheToStale) throws EBufException
op
- the opcode to performflags
- the control flags for opcodein
- the opcode parameter FList
setCacheToStale
- parameter to indicate whether to stale the cache or not.FList
modelEBufException
- EBufException thrown for Portal errorspublic FList opcode(int op, int flags, PModelHandle in, boolean setCacheToStale) throws EBufException
op
- the opcode to performflags
- the control flags for opcodein
- the opcode parameter PModelHandle
setCacheToStale
- parameter to indicate whether to stale the cache or not.FList
modelEBufException
- EBufException thrown for Portal errorspublic FList search(int op, FList in, boolean cacheResults) throws EBufException
op
- opcodein
- input flistcacheResults
- indicates whether to cache the search results or notEBufException
public PModelHandle[] search(int op, FList in) throws EBufException
search
opcode, but returns an array of model handles.opcode
- an Portal search opcode (SEARCH, STEP_SEARCH, STEP_NEXT
)in
- the opcode input FList
EBufException
- thrown if an error occurspublic PModelHandle[] search(int op, int flag, FList in) throws EBufException
search
opcode, but returns an array of model handles.op
- Portal search opcode (SEARCH, STEP_SEARCH, STEP_NEXT
)flag
- Flag to search opcodein
- Input FList
EBufException
- thrown if an error occurspublic PModelHandle getOrCreateModelFrom(FList fl) throws EBufException
Flist
, but doesn't put
the flist in the cache unless the created model handle has no match.fl
- the model to create a handle forEBufException
- thrown if an error occurspublic PModelHandle createModelFrom(FList fl, String type) throws EBufException
Flist
,
and sets that Flist
in the cache.fl
- the model to create a handle fortype
- the new model typeEBufException
- thrown if an error occurspublic PModelHandle createModelFrom(FList fl) throws EBufException
Flist
and sets that
Flist
in the cache.fl
- the model to create a handle forEBufException
- thrown if an error occurspublic PModelHandle createModelFrom(SparseArray sa) throws EBufException
SparseArray
.sa
- the model to create a handle forEBufException
- thrown if an error occurspublic PModelHandle createModelFrom(Poid pd) throws EBufException
Poid
.pd
- the model to create a handle forEBufException
- thrown if an error occurspublic Poid lookupPoid(PModelHandle modl) throws EBufException
Poid
from the cache for a model handle.modl
- the model handle to look upPoid
.EBufException
- thrown if an error occurspublic Object lookupModel(PModelHandle handle) throws EBufException
handle
. This method
simply calls lookupModel(PModelHandle, boolean, int)
,
passing false
for the second, and
PModelHandle.LOOKUP_UPDATE_IF_NEEDED
for the third
parameter.handle
- a non-null
PModelHandle
.handle
, or
null
.EBufException
- thrown if an error occurslookupModel(PModelHandle, boolean, int)
public Object lookupModel(PModelHandle handle, boolean ensureWhole, int updateFlag) throws EBufException
handle
. This method
calls PModelCache.lookupModel(PModelHandle, boolean, int)
to get
the model, and then if handle
is "collect-only", applies the
collected data in the handle to the model.handle
- a non-null
model handleensureWhole
- if true
, ensures that the model in the
cache is wholeupdateFlag
- if PModelHandle.LOOKUP_FORCE_UPDATE
,
the model is unconditionally updated with data from Portal; if
PModelHandle.LOOKUP_DONT_UPDATE
it is not. Otherwise, the
model is updated if marked stale, or if ensureWhole
is
true
and the model is not whole.handle
, or
null
.EBufException
- thrown if an error occurs while reading the object from
Portal.PModelCache#lookupModel(PModelHandle, boolean, int),
#lookupModel(PModelHandle)
public void setModel(PModelHandle modl, FList fl)
Flist
model in the cache associated with a handle.modl
- the PModelHandle
to use as a keyfl
- the model to storepublic void setModel(PModelHandle modl, SparseArray sa)
SparseArray
model in the cache associated with a handle.modl
- the PModelHandle
to use as a keysa
- the model to storepublic void setModel(PModelHandle modl, Poid pd)
Poid
model in the cache associated with a handle.modl
- the PModelHandle
to use as a keypd
- the model to storepublic void discardModel(PModelHandle mh)
mh
- a PModelHandle
public Object getModelField(FList data, PFieldSpecification spec) throws EBufException
Flist
model. This version only returns a model handle
for a field that is itself a model. Use this method when the returned field
data will be sent to the client. In the case of
PCompoundFieldSpec
, an object array is returned.data
- the model to get a field fromspec
- a specification for which field(s) to getEBufException
- thrown if an error occurspublic Object getModelField(PModelHandle data, PFieldSpecification spec) throws EBufException
PCompoundFieldSpec
, an object array is returned.data
- the model to get a field fromspec
- a specification for which field(s) to getEBufException
- thrown if an error occurspublic FList getWholeObject(PModelHandle mh) throws EBufException
mh
- a PModelHandle
Flist
object.EBufException
- thrown if an error occursRemoteException
- thrown if an error occurspublic FList getWholeObject(PModelHandle mh, boolean force) throws EBufException
mh
- a PModelHandle
force
- a flag to force a PCM_OP_READ_OBJ
EBufException
- thrown if an error occurspublic Object getField(FList list, PDataFieldSpecification spec) throws EBufException
Flist
model.list
- the model to get a field fromspec
- a specification of which field to getEBufException
- thrown if an error occurspublic Object getField(PModelHandle mh, PDataFieldSpecification spec) throws EBufException
mh
- the model to get a field fromspec
- a specification of which field to getEBufException
- thrown if an error occurspublic void setField(PModelHandle modl, PDataFieldSpecification spec, Object val) throws EBufException
modl
- the model to set a field inspec
- a specification of which field to setval
- the new value to setEBufException
- thrown if an error occurspublic void setField(FList list, PDataFieldSpecification spec, Object val) throws EBufException
Flist
field in a model to the specified value.list
- the model to set a field inspec
- a specification of which field to setval
- the new value to setEBufException
- thrown if an error occurspublic com.portal.permission.ScopeEntryPoint getScope() throws com.portal.permission.CredentialException
com.portal.permission.CredentialException
public void logCache()
Copyright © 2003, 2023, Oracle and/or its affiliates.