private void returnSriSuccess(CorrelationIdValue correlationIdValue) { int inProcess = this.getInProcess(); if (inProcess == 0) // SriSucess or Failure is already processed return; HrSriClientSbbLocalObject local = (HrSriClientSbbLocalObject) super.sbbContext.getSbbLocalObject(); HrSriResultInterface parent = (HrSriResultInterface) local.getParent(); parent.onSriSuccess(correlationIdValue, false); }
private void returnSriHrByPass(CorrelationIdValue correlationIdValue) { int inProcess = this.getInProcess(); if (inProcess == 0) // SriSucess or Failure is already processed return; HrSriClientSbbLocalObject local = (HrSriClientSbbLocalObject) super.sbbContext.getSbbLocalObject(); HrSriResultInterface parent = (HrSriResultInterface) local.getParent(); parent.onSriHrByPass(correlationIdValue); }
/** * @return */ private ServerTransaction getRegisterTransactionToReply() { ActivityContextInterface[] acis = this.sbbContextExt.getActivities(); Object activity = null; for (ActivityContextInterface aci : acis) { activity = aci.getActivity(); if (activity instanceof ServerTransaction) { // detach to not handle the activity end aci.detach(sbbContextExt.getSbbLocalObject()); return (ServerTransaction) activity; } } return null; }
/** * Simple method to create JDBC activity and execute given task. * * @param jdbcTask */ private void executeTask(SimpleJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF.getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
/** * Simple method to create JDBC activity and execute given task. * * @param queryJDBCTask */ private void executeTask(DataSourceJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF .getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
private void returnSriFailure(CorrelationIdValue correlationIdValue, MAPErrorMessage errorResponse, String cause) { int inProcess = this.getInProcess(); if (inProcess == 0) // SriSuccess or Failure is already processed return; this.setInProcess(0); HrSriClientSbbLocalObject local = (HrSriClientSbbLocalObject) super.sbbContext.getSbbLocalObject(); HrSriResultInterface parent = (HrSriResultInterface) local.getParent(); parent.onSriFailure(correlationIdValue, errorResponse, cause); }
public RatingInfo getRateForServiceAsync(HashMap params) { String sessionIdFromRequest = params.get("SessionId").toString(); HttpClientActivity clientActivity = null; try { clientActivity = raSbbInterface.createHttpClientActivity(true, null); } catch (StartActivityException e) { tracer.severe("[xx] Failed creating HTTP Client Activity to send HTTP Request to Rating Engine."); return new RatingInfo(-1, sessionIdFromRequest); } ActivityContextInterface clientAci = httpClientAci.getActivityContextInterface(clientActivity); clientAci.attach(sbbContext.getSbbLocalObject()); params.put("startTime", System.currentTimeMillis()); HttpPost httpPost = buildHTTPRequest(params); // Asynchronous call clientActivity.execute(httpPost, params); tracer.info("[>>] Sent HTTP Request to Rating Client in asynchronous mode."); return null; }
public void onTimerEvent(TimerEvent timer, ActivityContextInterface aci) { // detach from this activity, we don't want to handle any other event on it aci.detach(this.sbbContextExt.getSbbLocalObject()); if (tracer.isInfoEnabled()) { tracer.info("[--] " + sidString + " Forcing Activity Termination '" + aci.getActivity() + "' due to timeout expire."); } // TODO: allow for different options, such as sending a RAR request. ((RoServerSessionActivity) aci.getActivity()).endActivity(); }
public void onResponseEvent(ResponseEvent event, ActivityContextInterface aci) { HttpResponse response = event.getHttpResponse(); if (tracer.isInfoEnabled()) { tracer.info("[<<] Received HTTP Response. Status Code = " + response.getStatusLine().getStatusCode()); if (tracer.isFineEnabled()) { try { tracer.fine("[<<] Received HTTP Response. Response Body = [" + EntityUtils.toString(response.getEntity()) + "]"); } catch (Exception e) { tracer.severe("[xx] Failed reading response body", e); } } } // end http activity ((HttpClientActivity) aci.getActivity()).endActivity(); // call back parent HashMap params = (HashMap) event.getRequestApplicationData(); RatingInfo ratInfo = buildRatingInfo(response, params); final DiameterChargingServer parent = (DiameterChargingServer) sbbContext.getSbbLocalObject().getParent(); parent.getRateForServiceResult(ratInfo); }
public void onResponseEvent(ResponseEvent event, ActivityContextInterface aci) { // get local object RESTClientEnablerChildSbbLocalObject child = (RESTClientEnablerChildSbbLocalObject) this.sbbContext .getSbbLocalObject(); // get parent RESTClientEnablerParent parent = (RESTClientEnablerParent) child .getParent(); // build response RESTClientEnablerResponse response = new RESTClientEnablerResponse( (RESTClientEnablerRequest) event.getRequestApplicationData(), event.getHttpResponse(), event.getException()); // pass it to parent parent.onResponse(child, response); }
public void onResponseEvent(ResponseEvent event, ActivityContextInterface aci) { // get local object RESTClientEnablerChildSbbLocalObject child = (RESTClientEnablerChildSbbLocalObject) this.sbbContext .getSbbLocalObject(); // get parent RESTClientEnablerParent parent = (RESTClientEnablerParent) child .getParent(); // build response RESTClientEnablerResponse response = new RESTClientEnablerResponse( (RESTClientEnablerRequest) event.getRequestApplicationData(), event.getHttpResponse(), event.getException()); // pass it to parent parent.onResponse(child, response); }
/** * Private methods */ private void sendXmlPayload(byte[] data) throws Exception { HttpClientActivity httpClientActivity = this.getHTTPClientActivity(); if (httpClientActivity == null) { httpClientActivity = this.httpClientProvider.createHttpClientActivity(false, null); this.httpClientActivityContextInterfaceFactory.getActivityContextInterface(httpClientActivity).attach( this.sbbContext.getSbbLocalObject()); } this.httpClientActivityContextInterfaceFactory.getActivityContextInterface(httpClientActivity).attach( this.sbbContext.getSbbLocalObject()); String route = this.getNetworkRoutingRule().getRuleUrl(); HttpPost uriRequest = createRequest(route, null, ACCEPTED_CONTENT_TYPE, null); // NOTE: here we assume that its text/xml utf8 encoded... bum. pushContent(uriRequest, ACCEPTED_CONTENT_TYPE, CONTENT_ENCODING, data); if (logger.isFineEnabled()) { logger.fine("Executing HttpPost=" + uriRequest + "\n" + new String(data)); } httpClientActivity.execute(uriRequest, null); }
public void onSimpleJdbcTaskResultEvent(SimpleJdbcTaskResultEvent event, ActivityContextInterface aci) { if (tracer.isFineEnabled()) { tracer.fine("Received a SimpleJdbcTaskResultEvent, as result of executed task " + event.getTask()); } // end jdbc activity ((JdbcActivity) aci.getActivity()).endActivity(); // call back parent final SbbLocalObject parent = sbbContextExt.getSbbLocalObject().getParent(); final DataSourceJdbcTask jdbcTask = (DataSourceJdbcTask) event.getTask(); jdbcTask.callBackParentOnResult(parent); }
public void onSimpleJdbcTaskResultEvent(SimpleJdbcTaskResultEvent event, ActivityContextInterface aci) { if (tracer.isFineEnabled()) { tracer.fine("Received a SimpleJdbcTaskResultEvent, as result of executed task " + event.getTask()); } // end jdbc activity final JdbcActivity activity = (JdbcActivity) aci.getActivity(); activity.endActivity(); // call back parent final DataSourceParentSbbLocalInterface parent = (DataSourceParentSbbLocalInterface) sbbContextExt .getSbbLocalObject().getParent(); final DataSourceJdbcTask jdbcTask = (DataSourceJdbcTask) event .getTask(); jdbcTask.callBackParentOnResult(parent); }
/** * Event handler for {@link JdbcTaskExecutionThrowableEvent}. * * @param event * @param aci */ public void onJdbcTaskExecutionThrowableEvent(JdbcTaskExecutionThrowableEvent event, ActivityContextInterface aci) { if (tracer.isWarningEnabled()) { tracer.warning("Received a JdbcTaskExecutionThrowableEvent, as result of executed task " + event.getTask(), event.getThrowable()); } // end jdbc activity ((JdbcActivity) aci.getActivity()).endActivity(); // call back parent final SbbLocalObject parent = sbbContextExt.getSbbLocalObject().getParent(); final DataSourceJdbcTask jdbcTask = (DataSourceJdbcTask) event.getTask(); jdbcTask.callBackParentOnException(parent); }
private void sendSRI(String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext, CorrelationIdValue correlationIdValue) { // Send out SRI MAPDialogSms mapDialogSms = null; try { // 1. Create Dialog first and add the SRI request to it mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, correlationIdValue.getNetworkId()); // 2. Create the ACI and attach this SBB ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms); sriDialogACI.attach(this.sbbContext.getSbbLocalObject()); // 3. Finally send the request mapDialogSms.send(); } catch (MAPException e) { if (mapDialogSms != null) { mapDialogSms.release(); } String reason = "Home routing: HrSriClientSbb: MAPException when sending SRI from sendSRI(): " + e.toString(); this.logger.severe(reason, e); this.returnSriFailure(correlationIdValue, null, reason); } }
/** * Event handler for {@link JdbcTaskExecutionThrowableEvent}. * * @param event * @param aci */ public void onJdbcTaskExecutionThrowableEvent( JdbcTaskExecutionThrowableEvent event, ActivityContextInterface aci) { if (tracer.isWarningEnabled()) { tracer.warning( "Received a JdbcTaskExecutionThrowableEvent, as result of executed task " + event.getTask(), event.getThrowable()); } // end jdbc activity final JdbcActivity activity = (JdbcActivity) aci.getActivity(); activity.endActivity(); // call back parent final DataSourceParentSbbLocalInterface parent = (DataSourceParentSbbLocalInterface) sbbContextExt .getSbbLocalObject().getParent(); final DataSourceJdbcTask jdbcTask = (DataSourceJdbcTask) event .getTask(); jdbcTask.callBackParentOnException(parent); }
public void onTimerEvent(TimerEvent timer, SbbActivityContextInterface aci) { // detach from this activity, we don't want to handle any other event on // it aci.detach(this.sbbContextExt.getSbbLocalObject()); // get data needed to remove binding from aci RegistrationBindingData data = aci.getData(); if (data == null) { // another service's timer event, ignore return; } try { DataSourceChildSbbLocalInterface child = (DataSourceChildSbbLocalInterface) getChildRelation() .create(ChildRelationExt.DEFAULT_CHILD_NAME); child.removeBinding(data.getContact(), data.getAddress()); } catch (Exception e) { tracer.severe("Exception invoking data source child sbb.", e); return; } // end the activity try { ((NullActivity) aci.getActivity()).endActivity(); } catch (Exception e) { tracer.warning("failed to end binding aci", e); } }
private void handleRequest(CreditControlInfo ccInfo) { if (tracer.isInfoEnabled()) { tracer.info("[><] SID<" + ccInfo.getSessionId() + "> Handling Credit-Control-Request..."); } if (bypass) { if (tracer.isInfoEnabled()) { tracer.info("[><] SID<" + ccInfo.getSessionId() + "> Bypassing Unit Reservation..."); } ccInfo.setSuccess(true); ((DiameterChargingServer)sbbContext.getSbbLocalObject().getParent()).resumeOnCreditControlRequest(ccInfo); } else { DataSource ds = null; try { ds = getDatasource(); if (ccInfo.getRequestedAction() == RequestedActionType.DIRECT_DEBITING) { ds.directDebitUnits(ccInfo); } else { ds.requestUnits(ccInfo); } } catch (Exception e) { tracer.severe("[xx] Unable to obtain Datasource Child SBB", e); } } }
public void onDIALOG_REQUEST(org.mobicents.slee.resource.cap.events.DialogRequest event, ActivityContextInterface aci/* , EventContext eventContext */) { CAPDialog capDialog = event.getCAPDialog(); XmlCAPDialog dialog = new XmlCAPDialog(capDialog.getApplicationContext(), capDialog.getLocalAddress(), capDialog.getRemoteAddress(), capDialog.getLocalDialogId(), capDialog.getRemoteDialogId()); int networkId = capDialog.getNetworkId(); dialog.setNetworkId(networkId); this.setXmlCAPDialog(dialog); NetworkRoutingRule networkRoutingRule = networkRoutingRuleManagement.getNetworkRoutingRule(networkId); if (networkRoutingRule == null) { String route = camlePropertiesManagement.getRoute(); if (logger.isFineEnabled()) { logger.fine("No NetworkRoutingRule configured for network-id " + networkId + " Using the default one " + route); } networkRoutingRule = new NetworkRoutingRule(); networkRoutingRule.setRuleUrl(route); } this.setNetworkRoutingRule(networkRoutingRule); if (networkRoutingRule.getRuleUrl() == null) { logger.warning("No routing rule defined for networkId " + networkId + " Disconnecting from ACI, no new messages will be processed"); aci.detach(this.sbbContext.getSbbLocalObject()); } camelStatAggregator.updateDialogsAllEstablished(); this.setStartDialogTime(System.currentTimeMillis()); }