本文整理了Java中org.jgroups.Message.getObject()
方法的一些代码示例,展示了Message.getObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getObject()
方法的具体详情如下:
包路径:org.jgroups.Message
类名称:Message
方法名:getObject
[英]Uses Java serialization to create an object from the buffer of the message. Note that this is dangerous when using your own classloader, e.g. inside of an application server ! Most likely, JGroups will use the system classloader to deserialize the buffer into an object, whereas (for example) a web application will want to use the webapp's classloader, resulting in a ClassCastException. The recommended way is for the application to use their own serialization and only pass byte[] buffer to JGroups.
[中]使用Java序列化从消息缓冲区创建对象。请注意,使用自己的类加载器(例如在应用程序服务器内部)时,这是危险的!最有可能的情况是,JGroups将使用系统类加载器将缓冲区反序列化为对象,而(例如)web应用程序将希望使用webapp的类加载器,从而导致ClassCastException。建议应用程序使用自己的序列化,只将字节[]缓冲区传递给JGroup。
代码示例来源:origin: wildfly/wildfly
public <T extends Object> T getObject() {
return getObject(null);
}
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
System.out.println("<< " + msg.getObject() + " [" + msg.getSrc() + "]");
}
});
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
String line="[" + msg.getSrc() + "]: " + msg.getObject();
System.out.println(line);
}
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
System.out.println("-- received msg " + msg.getObject() + " from " + msg.getSrc());
}
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
T obj=raw_msgs? (T)msg : (T)msg.getObject();
list.add(obj);
if(verbose) {
System.out.println((name() != null? name() + ":" : "") + " received message from " + msg.getSrc() + ": " + obj);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void receive(Message msg) {
DataMessage dataMessage = (DataMessage) msg.getObject();
switch (dataMessage.type) {
case DataMessage.FINISH:
testGroupMulticastOrder.memberFinished(msg.getSrc());
break;
case DataMessage.DATA:
if (start == 0) {
start = System.nanoTime();
}
synchronized (messageList) {
messageList.add(dataMessage.data);
}
receivedBytes += (dataMessage.data.getBytes().length + 1);
receivedMsgs++;
stop = System.nanoTime();
break;
default:
break;
}
}
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
Address sender=msg.getSrc();
System.out.println("<< " + msg.getObject() + " from " + sender);
Address dst=msg.getDest();
if(dst == null) {
Message rsp=new Message(msg.getSrc(), "this is a response");
try {
ch.send(rsp);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: wildfly/wildfly
public Object down(Message msg) {
if(msg.getLength() > 0) {
try {
Long payload=msg.getObject();
if(payload != null) {
if(payload == seqno) {
synchronized(this) {
if(num_discards < 3) {
num_discards++;
return null;
}
}
}
if(payload == duplicate) { // inject a duplicate message
super.down(msg); // pass it down, will passed down a second time by the default down_prot.down(evt)
}
}
}
catch(Throwable t) {
;
}
}
return down_prot.down(msg);
}
}
代码示例来源:origin: wildfly/wildfly
Result res=msg.getObject();
results.add(msg.getSrc(), res);
if(initiator && results.hasAllResponses()) {
ConfigChange config_change=msg.getObject();
handleConfigChange(config_change);
break;
handleConfigResponse(msg.getObject());
break;
代码示例来源:origin: wildfly/wildfly
/** Callback. Process the contents of the message; typically an _add() or _set() request */
public void receive(Message msg) {
Request req=null;
if(msg == null || msg.getLength() == 0)
return;
try {
req=msg.getObject();
String fqn=req.fqn;
switch(req.type) {
case Request.PUT:
if(req.key != null && req.value != null)
_put(fqn, req.key, req.value);
else
_put(fqn, req.data);
break;
case Request.REMOVE:
if(req.key != null)
_remove(fqn, req.key);
else
_remove(fqn);
break;
default:
if(log.isErrorEnabled()) log.error("type " + req.type + " unknown");
break;
}
}
catch(Exception ex) {
if(log.isErrorEnabled()) log.error("failed unmarshalling request: " + ex);
}
}
代码示例来源:origin: org.jboss.errai/errai-bus
public static Message getErraiMessage(final org.jgroups.Message message) {
return MessageFactory.createCommandMessage(IntrabusQueueSession.INSTANCE, String.valueOf(message.getObject()));
}
代码示例来源:origin: wildfly/wildfly
return up_prot.up(msg);
Request req=msg.getObject();
if(log.isTraceEnabled())
log.trace("[" + local_addr + "] <-- [" + msg.getSrc() + "] " + req);
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
/** Tries to read an object from the message's buffer and prints it */
public String toStringAsObject() {
if(buf == null) return null;
try {
Object obj=getObject();
return obj != null ? obj.toString() : "";
}
catch(Exception e) { // it is not an object
return "";
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void receive(Message msg) {
Object o;
try {
o=msg.getObject();
ta.append(o + " [" + msg.getSrc() + "]\n");
history.add(o);
}
catch(Exception e) {
ta.append("Chat.receive(): " + e);
}
}
代码示例来源:origin: org.apache.camel/camel-jgroups
public Exchange createExchange(Message message) {
Exchange exchange = createExchange();
exchange.getIn().setHeader(HEADER_JGROUPS_ORIGINAL_MESSAGE, message);
exchange.getIn().setHeader(HEADER_JGROUPS_SRC, message.getSrc());
exchange.getIn().setHeader(HEADER_JGROUPS_DEST, message.getDest());
exchange.getIn().setBody(message.getObject());
return exchange;
}
代码示例来源:origin: org.codehaus.hydra-cache/harmony
@Override
public void receive(Message msg) {
Validate.notNull(msg, "Response message can not be null");
Object payload = msg.getObject();
if (log.isDebugEnabled())
log.debug("Received message: " + msg + " with object: " + payload);
Validate.isTrue(payload instanceof ControlMessage);
ControlMessage controlMessage = (ControlMessage) payload;
handleControlMessage(controlMessage);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-observation-remote
@Override
public void receive(Message msg)
{
RemoteEventData remoteEvent = (RemoteEventData) msg.getObject();
this.logger.debug("Received JGroups remote event [{}]", remoteEvent);
getRemoteObservationManager().notify(remoteEvent);
}
}
代码示例来源:origin: org.atmosphere/atmosphere-jgroups
/** {@inheritDoc} */
@Override
public void receive(final Message message) {
final Object msg = message.getObject();
if (msg != null && BroadcastMessage.class.isAssignableFrom(msg.getClass())) {
BroadcastMessage b = BroadcastMessage.class.cast(msg);
if (b.getTopicId().equalsIgnoreCase(getID())) {
broadcastReceivedMessage(b.getMessage());
}
}
}
});
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void receive(Message msg) {
T obj=raw_msgs? (T)msg : (T)msg.getObject();
list.add(obj);
if(verbose) {
System.out.println((name() != null? name() + ":" : "") + " received message from " + msg.getSrc() + ": " + obj);
}
}
代码示例来源:origin: org.axonframework/axon-distributed-commandbus
@Override
public void receive(Message msg) {
Object message = msg.getObject();
if (message instanceof JoinMessage) {
processJoinMessage(msg, (JoinMessage) message);
} else if (message instanceof DispatchMessage) {
processDispatchMessage(msg, (DispatchMessage) message);
} else if (message instanceof ReplyMessage) {
processReplyMessage((ReplyMessage) message);
}
}
内容来源于网络,如有侵权,请联系作者删除!