本文整理汇总了Java中java.rmi.MarshalException类的典型用法代码示例。如果您正苦于以下问题:Java MarshalException类的具体用法?Java MarshalException怎么用?Java MarshalException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MarshalException类属于java.rmi包,在下文中一共展示了MarshalException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rethrowDeserializationException
import java.rmi.MarshalException; //导入依赖的package包/类
private void rethrowDeserializationException(IOException ioe)
throws ClassNotFoundException, IOException {
// specially treating for an UnmarshalException
if (ioe instanceof UnmarshalException) {
throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
// fetch one by one with UnmarshalException
} else if (ioe instanceof MarshalException) {
// IIOP will throw MarshalException wrapping a NotSerializableException
// when a server fails to serialize a response.
MarshalException me = (MarshalException)ioe;
if (me.detail instanceof NotSerializableException) {
throw (NotSerializableException)me.detail;
}
}
// Not serialization problem, return.
}
示例2: StreamRemoteCall
import java.rmi.MarshalException; //导入依赖的package包/类
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
throws RemoteException
{
try {
conn = c;
Transport.transportLog.log(Log.VERBOSE,
"write remote call header...");
// write out remote call header info...
// call header, part 1 (read by Transport)
conn.getOutputStream().write(TransportConstants.Call);
getOutputStream(); // creates a MarshalOutputStream
id.write(out); // object id (target of call)
// call header, part 2 (read by Dispatcher)
out.writeInt(op); // method number (operation index)
out.writeLong(hash); // stub/skeleton hash
} catch (IOException e) {
throw new MarshalException("Error marshaling call header", e);
}
}
示例3: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
@Override
public void serialize(Element beanElement, Object object) throws MarshalException {
if (beanElement.getParentNode().equals(beanElement.getOwnerDocument())) {
beanElement.setAttribute("id", "e-" + m_count++);
SpringXMLSerializer serializer = (SpringXMLSerializer) XMLSerializationManager.getSerializer("spring");
String scope = serializer.getDefaultScope();
if (scope != null) {
beanElement.setAttribute("scope", scope);
}
beanElement.setAttribute("lazy-init", String.valueOf(serializer.isDefaultLazyInit()));
}
if (Proxy.isProxyClass(object.getClass())) {
String className;
String[] tokens = object.toString().split("@");
className = tokens[0];
beanElement.setAttribute("class", className);
}
else
beanElement.setAttribute("class", object.getClass().getCanonicalName());
super.serialize(beanElement, object);
}
示例4: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
public void serialize(Element containingElement, Object object) throws MarshalException {
boolean isProps = object instanceof Properties;
String entryElementName = isProps ? "prop" : "entry";
Document doc = containingElement.getOwnerDocument();
Element mapElement = doc.createElement(isProps ? "props" : "map");
containingElement.appendChild(mapElement);
for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
Element entryElement = doc.createElement(entryElementName);
entryElement.setAttribute("key", key);
mapElement.appendChild(entryElement);
if (isProps) {
entryElement.appendChild(doc.createTextNode(value.toString()));
}
else {
XMLSerializationManager.getSerializer("spring").serialize(entryElement, value);
}
}
}
示例5: writeObject
import java.rmi.MarshalException; //导入依赖的package包/类
/**
* @com.intel.drl.spec_ref
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
if (ref == null) {
// rmi.17=Invalid remote object: RemoteRef = null
throw new MarshalException(Messages.getString("rmi.17")); //$NON-NLS-1$
}
String refType = ref.getRefClass(out);
if (refType != null && refType.length() != 0) {
out.writeUTF(refType);
ref.writeExternal(out);
} else {
out.writeUTF(""); //$NON-NLS-1$
out.writeObject(ref);
}
}
示例6: handleCall
import java.rmi.MarshalException; //导入依赖的package包/类
/**
* Receives a {@link Message} object containing the method call
* request, executes the call, and writes the results to the client.
*
* @param msg The {@link Message} object containing the call execution request.
*
* @throws MarshalException if an exception occurs when writing the result
* of the call.
*/
protected void handleCall(Message msg) throws MarshalException {
UID dgcAck = null;
ReturnMessage methodExecuted = executeMethod(msg);
try {
dgcAck = methodExecuted.write(out);
out.flush();
} catch (IOException e) {
throw new MarshalException("Error writing method result", e);
}
if (dgcAck != null) {
dgcAckWaitingMap.put(dgcAck, new Pair<Long, Object>(new Long(System
.currentTimeMillis()
+ dgcAckMapTimeOut), methodExecuted.getResult()));
}
}
示例7: establishConnection
import java.rmi.MarshalException; //导入依赖的package包/类
/**
* Establishes a connection.
* <li>If {@link #lastUsageTime} is <code>null</code> then starts a
* connection.
* <li>If the difference between current time and {@link #lastUsageTime} is
* bigger or equal than double of the value stored in the table then renew
* the connection. The multiplied constant 2 is suggested in this
* {@link <a href="http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3">link</a>}
*
* @throws MarshalException
* if a {@link java.io.IOException} occurs while
* marshalling the remote call header, arguments or return value
* for a remote method call
* @throws IOException
* if the socket is closed
* @throws ProtocolException
* if there is an error in the underlying protocol
*/
@Override
public final void establishConnection() throws MarshalException,
IOException, ProtocolException {
if (lastUsageTime == null) {
// Initially, by default 1 millisecond.
handshake();
rttTable.put(this.ep, new Long(1));
lastUsageTime = System.currentTimeMillis();
} else if (System.currentTimeMillis() - this.lastUsageTime >= (rttTable
.get(this.ep) * 2)) {
// The multiplied constant 2 is suggested in
// http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3.
Long sentTime = System.currentTimeMillis();
protocolHandler.writePing(); // renewConnection();
out.flush();
protocolHandler.readPingAck();
rttTable.put(ep, System.currentTimeMillis() - sentTime);
}
}
示例8: main
import java.rmi.MarshalException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6332349\n");
Ping impl = new PingImpl();
Reference<?> ref = new WeakReference<Ping>(impl);
try {
Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
Object notSerializable = new Object();
stub.ping(impl, null);
try {
stub.ping(impl, notSerializable);
} catch (MarshalException e) {
if (e.getCause() instanceof NotSerializableException) {
System.err.println("ping invocation failed as expected");
} else {
throw e;
}
}
} finally {
UnicastRemoteObject.unexportObject(impl, true);
}
impl = null;
// Might require multiple calls to System.gc() for weak-references
// processing to be complete. If the weak-reference is not cleared as
// expected we will hang here until timed out by the test harness.
while (true) {
System.gc();
Thread.sleep(20);
if (ref.get() == null) {
break;
}
}
System.err.println("TEST PASSED");
}
示例9: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
public void serialize(Element containingElement, Object object) throws MarshalException {
Collection<?> collection = (Collection<?>) object;
String elementName = collection instanceof Set ? "set" : "list";
Element listElement = containingElement.getOwnerDocument().createElement(elementName);
containingElement.appendChild(listElement);
for (Object item : collection) {
XMLSerializationManager.getSerializer("spring").serialize(listElement, item);
}
}
示例10: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
@Override
public void serialize(Element containingElement, Object object) throws MarshalException {
Element element = containingElement;
IXmlSerializer xs = getSerializer(object, Object.class);
if (xs.getClass() == SpringBeanSerializer.class && !element.getNodeName().equals("bean")) {
element = containingElement.getOwnerDocument().createElement("bean");
containingElement.appendChild(element);
}
xs.serialize(element, object);
}
示例11: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
public void serialize(Element containingElement, Object object) throws MarshalException {
Map<?, ?> map = (Map<?, ?>) object;
Element mapElement = containingElement.getOwnerDocument().createElement("map");
containingElement.appendChild(mapElement);
for (Map.Entry<?, ?> entry : map.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
Element entryElement = mapElement.getOwnerDocument().createElement("entry");
entryElement.setAttribute("key", key);
mapElement.appendChild(entryElement);
XMLSerializationManager.getSerializer("spring").serialize(entryElement, value);
}
}
示例12: serialize
import java.rmi.MarshalException; //导入依赖的package包/类
public void serialize(Element containingElement, Object object) throws MarshalException {
Document d = containingElement.getOwnerDocument();
String value = object + "";
String name = containingElement.getNodeName();
if (object == null || name.equals("list") || name.equals("set") || name.equals("entry")) {
Element element = d.createElement(object == null ? "null" : "value");
containingElement.appendChild(element);
if (object != null) {
element.appendChild(d.createTextNode(value));
}
}
else {
containingElement.setAttribute("value", value);
}
}
示例13: serializeProperty
import java.rmi.MarshalException; //导入依赖的package包/类
@Override
protected void serializeProperty(Element beanElement, String propertyName, Object propertyValue)
throws MarshalException {
Element propertyElement = beanElement.getOwnerDocument().createElement("property");
propertyElement.setAttribute("name", propertyName);
beanElement.appendChild(propertyElement);
XMLSerializationManager.getSerializer("spring").serialize(propertyElement, propertyValue);
}
示例14: getXMLRepresentation
import java.rmi.MarshalException; //导入依赖的package包/类
/**
* Serializes an object to its XML representation, in a DOM.
*
* @param object
* the object to serialize.
* @return the root Element of a DOM containing the serialized object.
*/
public Element getXMLRepresentation(Object object) {
Element root = getRootElement(object);
try {
getSerializer(object, XSerializable.class).serialize(root, object);
}
catch (MarshalException e) {
throw new RuntimeException(e);
}
return root;
}