servicegroupcontext.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 542 行 · 第 1/2 页
JAVA
542 行
//---------------------------------------------------------
// in order to handle future changes to the message
// context definition, be sure to maintain the
// object level identifiers
//---------------------------------------------------------
// serialization version ID
out.writeLong(serialVersionUID);
// revision ID
out.writeInt(revisionID);
//---------------------------------------------------------
// various simple fields
//---------------------------------------------------------
out.writeLong(getLastTouchedTime());
if (id == null) {
// generate an ID to use when this object is restored
id = UUIDGenerator.getUUID();
}
ObjectStateUtils.writeString(out, id, "ServiceGroupContext.id");
//---------------------------------------------------------
// properties
//---------------------------------------------------------
Map tmpMap = getProperties();
HashMap tmpHashMap = null;
if ((tmpMap != null) && (!tmpMap.isEmpty())) {
tmpHashMap = new HashMap(tmpMap);
}
ObjectStateUtils.writeHashMap(out, tmpHashMap, "ServiceGroupContext.properties");
//---------------------------------------------------------
// AxisServiceGroup
//---------------------------------------------------------
String axisServGrpMarker = "ServiceGroupContext.axisServiceGroup";
ObjectStateUtils.writeString(out, axisServGrpMarker, axisServGrpMarker);
if (axisServiceGroup == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
metaAxisServiceGroup = new MetaDataEntry(axisServiceGroup.getClass().getName(),
axisServiceGroup.getServiceGroupName());
ObjectStateUtils.writeObject(out, metaAxisServiceGroup,
"ServiceGroupContext.metaAxisServiceGroup");
}
//---------------------------------------------------------
// parent
//---------------------------------------------------------
// the parent is the ConfigurationContext object, which
// at this time, is not being saved.
// instead, we will need to register this ServiceGroupObject
// with the existing ConfigurationContext object when
// this object is reconstituted
}
/**
* Restore the contents of the object that was previously saved.
* <p/>
* NOTE: The field data must read back in the same order and type
* as it was written. Some data will need to be validated when
* resurrected.
*
* @param in The stream to read the object contents from
* @throws IOException
* @throws ClassNotFoundException
*/
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// set the flag to indicate that the message context is being
// reconstituted and will need to have certain object references
// to be reconciled with the current engine setup
needsToBeReconciled = true;
// trace point
if (log.isTraceEnabled()) {
log.trace(myClassName + ":readExternal(): BEGIN bytes available in stream [" +
in.available() + "] ");
}
// serialization version ID
long suid = in.readLong();
// revision ID
int revID = in.readInt();
// make sure the object data is in a version we can handle
if (suid != serialVersionUID) {
throw new ClassNotFoundException(ObjectStateUtils.UNSUPPORTED_SUID);
}
// make sure the object data is in a revision level we can handle
if (revID != REVISION_1) {
throw new ClassNotFoundException(ObjectStateUtils.UNSUPPORTED_REVID);
}
//---------------------------------------------------------
// various simple fields
//---------------------------------------------------------
long time = in.readLong();
setLastTouchedTime(time);
id = ObjectStateUtils.readString(in, "ServiceGroupContext.id");
//---------------------------------------------------------
// properties
//---------------------------------------------------------
HashMap tmpHashMap = ObjectStateUtils.readHashMap(in, "ServiceGroupContext.properties");
properties = new HashMap();
if (tmpHashMap != null) {
setProperties(tmpHashMap);
}
//---------------------------------------------------------
// AxisServiceGroup
//---------------------------------------------------------
// axisServiceGroup is not usable until the meta data has been reconciled
axisServiceGroup = null;
ObjectStateUtils.readString(in, "ServiceGroupContext.axisServiceGroup");
boolean metaAxisServiceGrpIsActive = in.readBoolean();
if (metaAxisServiceGrpIsActive == ObjectStateUtils.ACTIVE_OBJECT) {
metaAxisServiceGroup = (MetaDataEntry) ObjectStateUtils
.readObject(in, "ServiceGroupContext.metaAxisServiceGroup");
} else {
metaAxisServiceGroup = null;
}
//---------------------------------------------------------
// parent
//---------------------------------------------------------
// the parent is the ConfigurationContext object, whic
// at this time, is not being saved.
// instead, we will need to register this ServiceGroupObject
// with the existing ConfigurationContext object when
// this object is reconstituted
//---------------------------------------------------------
// other
//---------------------------------------------------------
serviceContextMap = new HashMap();
//---------------------------------------------------------
// done
//---------------------------------------------------------
}
/**
* Some parts of the object restored from the
* readExternal deserialization work cannot be completed until
* we have a configurationContext. This method checks to see
* if additional work needs to be done in order to complete
* the object reconstitution.
*
* @param cc the active ConfigurationContext
*/
public void activate(ConfigurationContext cc) {
// see if there's any work to do
if (!needsToBeReconciled) {
// return quick
return;
}
// get the axis configuration
AxisConfiguration axisConfig = cc.getAxisConfiguration();
// We previously saved metaAxisServiceGroup; restore it
if (metaAxisServiceGroup != null) {
axisServiceGroup = ObjectStateUtils.findServiceGroup(axisConfig,
metaAxisServiceGroup.getClassName(),
metaAxisServiceGroup.getQNameAsString());
} else {
axisServiceGroup = null;
}
// set parent
this.setParent(cc);
// register with the parent
cc.addServiceGroupContextIntoSoapSessionTable(this);
//-------------------------------------------------------
// done, reset the flag
//-------------------------------------------------------
needsToBeReconciled = false;
}
/**
* Compares key parts of the state from the current instance of
* this class with the specified instance to see if they are
* equivalent.
* <p/>
* This differs from the java.lang.Object.equals() method in
* that the equals() method generally looks at both the
* object identity (location in memory) and the object state
* (data).
* <p/>
*
* @param ctx The object to compare with
* @return TRUE if this object is equivalent with the specified object
* that is, key fields match
* FALSE, otherwise
*/
public boolean isEquivalent(ServiceGroupContext ctx) {
// NOTE: the input object is expected to exist (ie, be non-null)
if (!this.axisServiceGroup.equals(ctx.getDescription())) {
return false;
}
String ctxid = ctx.getId();
if ((this.id != null) && (ctxid != null)) {
if (!this.id.equals(ctxid)) {
return false;
}
} else if ((this.id == null) && (ctxid == null)) {
// keep going
} else {
// mismatch
return false;
}
// TODO: consider checking the parent objects for equivalency
// TODO: consider checking fields from the super class for equivalency
return true;
}
/**
* Trace a warning message, if needed, indicating that this
* object needs to be activated before accessing certain fields.
*
* @param methodname The method where the warning occurs
*/
private void checkActivateWarning(String methodname) {
if (needsToBeReconciled) {
log.warn(myClassName + ":" + methodname + "(): ****WARNING**** " + myClassName +
".activate(configurationContext) needs to be invoked.");
}
}
public ConfigurationContext getRootContext() {
//parent of the ServiceGroupContext is the ConfigurationContext
return (ConfigurationContext) this.getParent();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?