本文整理汇总了Java中com.caucho.hessian.io.HessianInput类的典型用法代码示例。如果您正苦于以下问题:Java HessianInput类的具体用法?Java HessianInput怎么用?Java HessianInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HessianInput类属于com.caucho.hessian.io包,在下文中一共展示了HessianInput类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
public static <T> Object deserialize(byte[] bytes, Class<T> clazz) {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
HessianInput hi = new HessianInput(is);
try {
return hi.readObject();
} catch (IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例2: deserialize
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
public <T> T deserialize(byte[] data, Class<T> clazz) {
if (data == null)
throw new NullPointerException();
try {
ByteArrayInputStream is = new ByteArrayInputStream(data);
HessianInput hi = new HessianInput(is);
return (T) hi.readObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: getHessianInput
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
public AbstractHessianInput getHessianInput(InputStream is)
{
AbstractHessianInput in = new HessianInput(is);
in.setRemoteResolver(getRemoteResolver());
return in;
}
示例4: copy
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
public void copy(final String remoteFileName, final OutputStream outputTo) throws IOException {
InputStream responceIS = null;
OutputStream connectionOS = null;
InputStream connectionIS = null;
try {
// call backend
final URLConnection conn = proxyFactory.openConnection(new URL(webServiceLocator.getURL()));
conn.addRequestProperty(WebServiceConstants.REQUEST_HEADER_CUSTOM_PROTOCOL, Boolean.toString(true));
conn.connect();
connectionOS = conn.getOutputStream();
final HessianOutput ho = proxyFactory.getHessianOutput(connectionOS);
ho.startCall(WebServiceConstants.METHOD_GET_FILE);
ho.writeString(remoteFileName);
ho.completeCall();
connectionOS.close();
// read response
connectionIS = conn.getInputStream();
final HessianInput hin = new HessianInput(connectionIS);
try {
hin.startReply();
} catch (Throwable throwable) { // NOPMD - because startReply, thanks to caucho, declares Throwable
if (throwable instanceof IOException) throw (IOException)throwable; // NOPMD - we still have to know what is the exception
final IOException e = new IOException(StringUtils.toString(throwable));
e.initCause(throwable);
throw e;
}
responceIS = hin.readInputStream();
IoUtils.copyInputToOuputStream(responceIS, outputTo);
hin.completeReply();
} finally {
IoUtils.closeHard(connectionIS);
IoUtils.closeHard(connectionOS);
IoUtils.closeHard(responceIS);
}
}
示例5: deserialize
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
@Override
public <T> Object deserialize(byte[] bytes, Class<T> clazz) {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
HessianInput hi = new HessianInput(is);
try {
return hi.readObject();
} catch (IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例6: beforeProviderInvokeForSVC
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
private void beforeProviderInvokeForSVC(Invocation invocation, TransactionRequestImpl request,
TransactionResponseImpl response) {
CompensableBeanRegistry beanRegistry = CompensableBeanRegistry.getInstance();
CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory();
TransactionInterceptor transactionInterceptor = beanFactory.getTransactionInterceptor();
RemotingException rpcError = null;
String transactionContextContent = invocation.getAttachment(TransactionContext.class.getName());
String propagatedBy = invocation.getAttachment(RemoteCoordinator.class.getName());
if (StringUtils.isNotBlank(transactionContextContent)) {
byte[] requestByteArray = ByteUtils.stringToByteArray(transactionContextContent);
ByteArrayInputStream bais = new ByteArrayInputStream(requestByteArray);
HessianInput input = new HessianInput(bais);
try {
TransactionContext remoteTransactionContext = (TransactionContext) input.readObject();
remoteTransactionContext.setPropagatedBy(propagatedBy);
request.setTransactionContext(remoteTransactionContext);
} catch (IOException ex) {
logger.error("Error occurred in remote call!", ex);
rpcError = new RemotingException(ex.getMessage());
}
}
try {
transactionInterceptor.afterReceiveRequest(request);
} catch (RuntimeException rex) {
logger.error("Error occurred in remote call!", rex);
throw new RemotingException(rex.getMessage());
}
if (rpcError != null) {
throw rpcError;
}
}
示例7: afterConsumerInvokeForSVC
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
private void afterConsumerInvokeForSVC(Invocation invocation, TransactionRequestImpl request,
TransactionResponseImpl response) {
CompensableBeanRegistry beanRegistry = CompensableBeanRegistry.getInstance();
CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory();
TransactionInterceptor transactionInterceptor = beanFactory.getTransactionInterceptor();
RemotingException rpcError = null;
try {
if (request.getTransactionContext() != null) {
String transactionContextContent = invocation.getAttachment(TransactionContext.class.getName());
byte[] byteArray = ByteUtils.stringToByteArray(transactionContextContent);
ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
HessianInput input = new HessianInput(bais);
TransactionContext remoteTransactionContext = (TransactionContext) input.readObject();
response.setTransactionContext(remoteTransactionContext);
}
} catch (IOException ex) {
logger.error("Error occurred in remote call!", ex);
rpcError = new RemotingException(ex.getMessage());
}
try {
transactionInterceptor.afterReceiveResponse(response);
} catch (RuntimeException rex) {
logger.error("Error occurred in remote call!", rex);
throw new RemotingException(rex.getMessage());
}
if (rpcError != null) {
throw rpcError;
}
}
示例8: deserialize
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
@Override
public Object deserialize(byte[] data) {
ByteArrayInputStream is = new ByteArrayInputStream(data);
HessianInput hi = new HessianInput(is);
Object obj=null;
try {
obj = hi.readObject();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return obj;
}
示例9: beforeProviderInvokeForSVC
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
private void beforeProviderInvokeForSVC(Invocation invocation, TransactionRequestImpl request,
TransactionResponseImpl response) {
TransactionBeanRegistry beanRegistry = TransactionBeanRegistry.getInstance();
TransactionBeanFactory beanFactory = beanRegistry.getBeanFactory();
TransactionInterceptor transactionInterceptor = beanFactory.getTransactionInterceptor();
RpcException rpcError = null;
String transactionContextContent = invocation.getAttachment(TransactionContext.class.getName());
String propagatedBy = invocation.getAttachment(RemoteCoordinator.class.getName());
if (StringUtils.isNotBlank(transactionContextContent)) {
byte[] requestByteArray = ByteUtils.stringToByteArray(transactionContextContent);
ByteArrayInputStream bais = new ByteArrayInputStream(requestByteArray);
HessianInput input = new HessianInput(bais);
try {
TransactionContext remoteTransactionContext = (TransactionContext) input.readObject();
remoteTransactionContext.setPropagatedBy(propagatedBy);
request.setTransactionContext(remoteTransactionContext);
} catch (IOException ex) {
logger.error("Error occurred in remote call!", ex);
rpcError = new RpcException("Error occurred in remote call!", ex);
}
}
try {
transactionInterceptor.afterReceiveRequest(request);
} catch (RuntimeException rex) {
logger.error("Error occurred in remote call!", rex);
throw new RpcException("Error occurred in remote call!", rex);
}
if (rpcError != null) {
throw rpcError;
}
}
示例10: afterConsumerInvokeForSVC
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
private void afterConsumerInvokeForSVC(Invocation invocation, TransactionRequestImpl request,
TransactionResponseImpl response) {
TransactionBeanRegistry beanRegistry = TransactionBeanRegistry.getInstance();
TransactionBeanFactory beanFactory = beanRegistry.getBeanFactory();
TransactionInterceptor transactionInterceptor = beanFactory.getTransactionInterceptor();
RpcException rpcError = null;
try {
if (request.getTransactionContext() != null) {
String transactionContextContent = invocation.getAttachment(TransactionContext.class.getName());
byte[] byteArray = ByteUtils.stringToByteArray(transactionContextContent);
ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
HessianInput input = new HessianInput(bais);
TransactionContext remoteTransactionContext = (TransactionContext) input.readObject();
response.setTransactionContext(remoteTransactionContext);
}
} catch (IOException ex) {
logger.error("Error occurred in remote call!", ex);
rpcError = new RpcException("Error occurred in remote call!", ex);
}
try {
transactionInterceptor.afterReceiveResponse(response);
} catch (RuntimeException rex) {
logger.error("Error occurred in remote call!", rex);
throw new RpcException("Error occurred in remote call!", rex);
}
if (rpcError != null) {
throw rpcError;
}
}
示例11: deserializeObject
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
public static Serializable deserializeObject(byte[] bytes) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
HessianInput hi = new HessianInput(bais);
Object result;
try {
result = hi.readObject();
return (Serializable) result;
} finally {
CommonUtils.closeQuietly(bais);
}
}
示例12: decode
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
@Override
public Object decode(InputStream in, ClassResolver classResolver) throws Exception
{
HessianInput hi = new HessianInput(in);
Object result = hi.readObject();
hi.close();
return result;
}
示例13: invoke
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
/**
* Invoke the object with the request from the input stream.
*
* @param in the Hessian input stream
* @param out the Hessian output stream
*/
public void invoke(HessianInput in, HessianOutput out)
throws Throwable
{
in.startCall();
Method method = getMethod(in.getMethod());
if (method != null) {
}
else if ("_hessian_getAttribute".equals(in.getMethod())) {
String attrName = in.readString();
in.completeCall();
String value = null;
if ("java.api.class".equals(attrName))
value = getAPIClassName();
else if ("java.home.class".equals(attrName))
value = getHomeClassName();
else if ("java.object.class".equals(attrName))
value = getObjectClassName();
out.startReply();
out.writeObject(value);
out.completeReply();
return;
}
else if (method == null) {
out.startReply();
out.writeFault("NoSuchMethodException",
"The service has no method named: " + in.getMethod(),
null);
out.completeReply();
return;
}
Class []args = method.getParameterTypes();
Object []values = new Object[args.length];
for (int i = 0; i < args.length; i++)
values[i] = in.readObject(args[i]);
in.completeCall();
Object result = null;
try {
result = method.invoke(_service, values);
} catch (Throwable e) {
if (e instanceof InvocationTargetException)
e = ((InvocationTargetException) e).getTargetException();
out.startReply();
out.writeFault("ServiceException", e.getMessage(), e);
out.completeReply();
return;
}
out.startReply();
out.writeObject(result);
out.completeReply();
}
示例14: createInput
import com.caucho.hessian.io.HessianInput; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.AbstractHessianBase#createInput(java.io.ByteArrayInputStream)
*/
@Override
protected AbstractHessianInput createInput ( ByteArrayInputStream bos ) {
return new HessianInput(bos);
}