/** * send client context with the request. The sendingRequest method of the JPortableInterceptors * is called prior to marshalling arguments and contexts * @param jri JClientRequestInfo the jrmp client info * @exception IOException if an exception occur with the ObjectOutput */ public void sendRequest(JClientRequestInfo jri) throws IOException { if (TraceTm.jta.isDebugEnabled()) { TraceTm.jta.debug("JTAClientTransactionInterceptor.sendRequest"); } try { if (current == null) { current = Current.getCurrent(); } if (current != null) { // get the Transaction Context (null if there is no transaction) TransactionContext txCtx = current.getPropagationContext(true); if (txCtx != null) { JTATransactionServiceContext jtasc = new JTATransactionServiceContext(); jtasc.setContext(txCtx, false); jri.addRequestServiceContext(jtasc); } } } catch (Exception e) { e.printStackTrace(); } }
public void send(final byte code, final ObjectOutput out) throws IOException { JClientRequestInfo info = new JRMPClientRequestInfoImpl(); for (JClientRequestInterceptor ci : cis) { ci.sendRequest(info); } Collection<JServiceContext> c = info.getAllRequestServiceContext(); out.writeShort(c.size()); for (JServiceContext jServiceContext : c) { out.writeObject(jServiceContext); } }
public void receiveException(JClientRequestInfo jri) throws IOException { if (TraceTm.jta.isDebugEnabled()) { TraceTm.jta.debug("JTAClientTransactionInterceptor.receiveException"); } if (current == null) { current = Current.getCurrent(); } if (current != null) { JTATransactionServiceContext jtasc = (JTATransactionServiceContext) jri.getReplyServiceContext( TX_CTX_ID); if (jtasc != null) { // put into the the Current object (true for client side context current.setPropagationContext( jtasc.getTransactionContext(), true); } } }
jrc.addRequestServiceContext((JServiceContext) in.readObject()); TraceCarol.debugRmiCarol("JClientInterceptorHelper getObjectFromInput local id(" + id + ")"); jrc.addAllRequestServiceContext((Collection<JServiceContext>) JContextStore.getObject(id)); return jrc; } else {
if (!ri.hasContexts()) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper send request without contexts"); Collection<JServiceContext> ctx = ri.getAllRequestServiceContext(); int k = JContextStore.storeObject(ctx); out.writeInt(LOCAL_CTX); Collection<JServiceContext> allCtx = ri.getAllRequestServiceContext(); out.writeInt(allCtx.size()); for (JServiceContext jsc : allCtx) {
private void getHAContext(final JClientRequestInfo jri) { // Get the HAContext from the received info HAServiceContext receivedCtx = (HAServiceContext) jri.getRequestServiceContext(HAServiceContext.HA_CTX_ID); if(receivedCtx == null) { return; } logger.debug("receivedCtx: " + receivedCtx); // Get the current Thread/HAContext association class HACurrent current = HACurrent.getHACurrent(); Stack<RequestId> requests = ((HAContext) receivedCtx.getContextData()).getRequests(); current.setRequests(requests); } }
public void receive(final byte code, final ObjectInput in) throws IOException, ClassNotFoundException { JClientRequestInfo info = new JRMPClientRequestInfoImpl(); int len = in.readShort(); for (int i = 0; i < len; i++) { info.addRequestServiceContext((JServiceContext) in.readObject()); } for (JClientRequestInterceptor ci : cis) { switch (code) { case METHOD_RESULT: ci.receiveReply(info); break; case METHOD_ERROR: case SYSTEM_ERROR: ci.receiveException(info); break; } } }
public void receiveOther(JClientRequestInfo jri) throws IOException { if (TraceTm.jta.isDebugEnabled()) { TraceTm.jta.debug("JTAClientTransactionInterceptor.receiveOther"); } if (current == null) { current = Current.getCurrent(); } if (current != null) { JTATransactionServiceContext jtasc = (JTATransactionServiceContext) jri.getReplyServiceContext( TX_CTX_ID); if (jtasc != null) { // put into the the Current object (true for client side context current.setPropagationContext( jtasc.getTransactionContext(), true); } } } }
/** * send client context with the request. The sendingRequest method of the * JPortableInterceptors is called prior to marshalling arguments and * contexts * @param JClientRequestInfo jri the jrmp client info * @exception IOException if an exception occur with the ObjectOutput */ public void sendRequest(final JClientRequestInfo jri) throws IOException { // Gets Current object (always existing in JOnAS Server) SecurityCurrent current = SecurityCurrent.getCurrent(); if (current != null) { // Get the Security Context SecurityContext ctx = current.getSecurityContext(); SecurityServiceContext ssc = new SecurityServiceContext(SEC_CTX_ID, ctx); jri.addRequestServiceContext(ssc); } }
/** * Receive reply interception * @param jri JClientRequestInfo the jrmp client info * @exception IOException if an exception occur with the ObjectOutput */ public void receiveReply(JClientRequestInfo jri) throws IOException { if (TraceTm.jta.isDebugEnabled()) { TraceTm.jta.debug("JTAClientTransactionInterceptor.receiveReply"); } if (current == null) { current = Current.getCurrent(); } if (current != null) { JTATransactionServiceContext jtasc = (JTATransactionServiceContext) jri.getReplyServiceContext( TX_CTX_ID); if (jtasc != null) { // put into the the Current object (true for client side context current.setPropagationContext( jtasc.getTransactionContext(), true); } } }
/** * Constructs the HAContext with the required replication information on * the client side */ public void sendRequest(final JClientRequestInfo jri) throws IOException { // Get the current HA Context info associated to the thread HACurrent current = HACurrent.getHACurrent(); // Fill the "req_id" field to propagate through the interceptor if the // nextReq has been included in the HA current context (held in the // thread-local variable) by the stub HAContext newHACtx = new HAContext(); Stack<RequestId> requests = current.getRequests(); newHACtx.setRequests(requests); newHACtx.setOnFailover(current.isOnFailover()); logger.debug("Propagating requests chain: " + newHACtx); // Create the new HAContext to propagate between interceptors HAServiceContext haServiceContext = new HAServiceContext(newHACtx); // Finally, include the new HAContext created to be propagated through // the interceptor jri.addRequestServiceContext(haServiceContext); }