PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/servers/jain-slee/resources/isup/ra/src/main/java/org/mobicents/slee/resources/isup/ra/IsupResourceAdaptor.java

http://mobicents.googlecode.com/
Java | 670 lines | 516 code | 85 blank | 69 comment | 19 complexity | 250e693ebb76e6ec2e501b8879006f79 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package org.mobicents.slee.resources.isup.ra;
  6. import java.io.IOException;
  7. import java.net.DatagramSocket;
  8. import java.net.InetAddress;
  9. import java.net.InetSocketAddress;
  10. import java.net.ServerSocket;
  11. import java.net.Socket;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. import java.util.Properties;
  15. import java.util.concurrent.Semaphore;
  16. import java.util.concurrent.ConcurrentHashMap;
  17. import javax.naming.InitialContext;
  18. import javax.slee.Address;
  19. import javax.slee.SLEEException;
  20. import javax.slee.facilities.EventLookupFacility;
  21. import javax.slee.facilities.Tracer;
  22. import javax.slee.resource.ActivityAlreadyExistsException;
  23. import javax.slee.resource.ActivityFlags;
  24. import javax.slee.resource.ActivityHandle;
  25. import javax.slee.resource.ConfigProperties;
  26. import javax.slee.resource.EventFlags;
  27. import javax.slee.resource.FailureReason;
  28. import javax.slee.resource.FireableEventType;
  29. import javax.slee.resource.InvalidConfigurationException;
  30. import javax.slee.resource.Marshaler;
  31. import javax.slee.resource.ReceivableService;
  32. import javax.slee.resource.ResourceAdaptor;
  33. import javax.slee.resource.ResourceAdaptorContext;
  34. import javax.slee.resource.SleeEndpoint;
  35. import javax.slee.resource.StartActivityException;
  36. import javax.slee.resource.ConfigProperties.Property;
  37. import org.mobicents.protocols.ss7.isup.ISUPListener;
  38. import org.mobicents.protocols.ss7.isup.ISUPMessageFactory;
  39. import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
  40. import org.mobicents.protocols.ss7.isup.ISUPProvider;
  41. import org.mobicents.protocols.ss7.isup.ISUPStack;
  42. import org.mobicents.protocols.ss7.isup.ISUPEvent;
  43. import org.mobicents.protocols.ss7.isup.ISUPTimeoutEvent;
  44. import org.mobicents.protocols.ss7.isup.ParameterException;
  45. import org.mobicents.protocols.ss7.isup.impl.ISUPStackImpl;
  46. import org.mobicents.protocols.ss7.isup.message.AddressCompleteMessage;
  47. import org.mobicents.protocols.ss7.isup.message.AnswerMessage;
  48. import org.mobicents.protocols.ss7.isup.message.ApplicationTransportMessage;
  49. import org.mobicents.protocols.ss7.isup.message.BlockingAckMessage;
  50. import org.mobicents.protocols.ss7.isup.message.BlockingMessage;
  51. import org.mobicents.protocols.ss7.isup.message.CallProgressMessage;
  52. import org.mobicents.protocols.ss7.isup.message.ChargeInformationMessage;
  53. import org.mobicents.protocols.ss7.isup.message.CircuitGroupBlockingAckMessage;
  54. import org.mobicents.protocols.ss7.isup.message.CircuitGroupBlockingMessage;
  55. import org.mobicents.protocols.ss7.isup.message.CircuitGroupQueryMessage;
  56. import org.mobicents.protocols.ss7.isup.message.CircuitGroupQueryResponseMessage;
  57. import org.mobicents.protocols.ss7.isup.message.CircuitGroupResetAckMessage;
  58. import org.mobicents.protocols.ss7.isup.message.CircuitGroupResetMessage;
  59. import org.mobicents.protocols.ss7.isup.message.CircuitGroupUnblockingAckMessage;
  60. import org.mobicents.protocols.ss7.isup.message.CircuitGroupUnblockingMessage;
  61. import org.mobicents.protocols.ss7.isup.message.ConfusionMessage;
  62. import org.mobicents.protocols.ss7.isup.message.ConnectMessage;
  63. import org.mobicents.protocols.ss7.isup.message.ContinuityCheckRequestMessage;
  64. import org.mobicents.protocols.ss7.isup.message.ContinuityMessage;
  65. import org.mobicents.protocols.ss7.isup.message.FacilityAcceptedMessage;
  66. import org.mobicents.protocols.ss7.isup.message.FacilityRejectedMessage;
  67. import org.mobicents.protocols.ss7.isup.message.ForwardTransferMessage;
  68. import org.mobicents.protocols.ss7.isup.message.ISUPMessage;
  69. import org.mobicents.protocols.ss7.isup.message.IdentificationRequestMessage;
  70. import org.mobicents.protocols.ss7.isup.message.IdentificationResponseMessage;
  71. import org.mobicents.protocols.ss7.isup.message.InitialAddressMessage;
  72. import org.mobicents.protocols.ss7.isup.message.LoopPreventionMessage;
  73. import org.mobicents.protocols.ss7.isup.message.LoopbackAckMessage;
  74. import org.mobicents.protocols.ss7.isup.message.NetworkResourceManagementMessage;
  75. import org.mobicents.protocols.ss7.isup.message.OverloadMessage;
  76. import org.mobicents.protocols.ss7.isup.message.PassAlongMessage;
  77. import org.mobicents.protocols.ss7.isup.message.PreReleaseInformationMessage;
  78. import org.mobicents.protocols.ss7.isup.message.ReleaseCompleteMessage;
  79. import org.mobicents.protocols.ss7.isup.message.ReleaseMessage;
  80. import org.mobicents.protocols.ss7.isup.message.ResetCircuitMessage;
  81. import org.mobicents.protocols.ss7.isup.message.ResumeMessage;
  82. import org.mobicents.protocols.ss7.isup.message.SubsequentAddressMessage;
  83. import org.mobicents.protocols.ss7.isup.message.SubsequentDirectoryNumberMessage;
  84. import org.mobicents.protocols.ss7.isup.message.SuspendMessage;
  85. import org.mobicents.protocols.ss7.isup.message.UnblockingAckMessage;
  86. import org.mobicents.protocols.ss7.isup.message.UnblockingMessage;
  87. import org.mobicents.protocols.ss7.isup.message.UnequippedCICMessage;
  88. import org.mobicents.protocols.ss7.isup.message.User2UserInformationMessage;
  89. import org.mobicents.protocols.ss7.isup.message.UserPartAvailableMessage;
  90. import org.mobicents.protocols.ss7.isup.message.UserPartTestMessage;
  91. import org.mobicents.protocols.ss7.isup.message.parameter.CauseIndicators;
  92. import org.mobicents.slee.resources.ss7.isup.events.TimeoutEvent;
  93. import org.mobicents.slee.resources.ss7.isup.events.BlockedEvent;
  94. import org.mobicents.slee.resources.ss7.isup.ratype.RAISUPProvider;
  95. import org.mobicents.slee.resources.ss7.isup.ratype.CircuitActivity;
  96. /**
  97. *
  98. * @author kulikov
  99. * @author baranowb
  100. */
  101. public class IsupResourceAdaptor implements ResourceAdaptor, ISUPListener {
  102. private Tracer tracer;
  103. private transient SleeEndpoint sleeEndpoint = null;
  104. /** the EventLookupFacility is used to look up the event id of incoming events */
  105. private transient EventLookupFacility eventLookupFacility = null;
  106. private FireableEventTypeCache eventTypeCache;
  107. private FireableEventTypeFilter eventTypeFilter;
  108. private ResourceAdaptorContext raContext;
  109. ////////////
  110. // Flafgs //
  111. ////////////
  112. private static final int EVENT_FLAGS = getEventFlags();
  113. private static final int ACTIVITY_FLAGS = getActivityFlags();
  114. private ConcurrentHashMap<ActivityHandle, CircuitActivity> activities = new ConcurrentHashMap<ActivityHandle, CircuitActivity>();
  115. /////////////////
  116. // RA Provider //
  117. /////////////////
  118. private RAISUPProviderImpl raProvider;
  119. // ////////////////////////////
  120. // Configuration parameters //
  121. // ////////////////////////////
  122. private static final String CONF_ISUP_JNDI = "isupJndi";
  123. private String isupJndi = null;
  124. /////////////////
  125. // ISUP stack //
  126. /////////////////
  127. private ISUPProvider isupProvider;
  128. private boolean transportUp = false;
  129. private int localspc,ni;
  130. private static int getEventFlags() {
  131. int eventFlags = EventFlags.REQUEST_EVENT_UNREFERENCED_CALLBACK;
  132. EventFlags.setRequestProcessingFailedCallback(eventFlags);
  133. return eventFlags;
  134. }
  135. private static int getActivityFlags() {
  136. return ActivityFlags.REQUEST_ENDED_CALLBACK;
  137. }
  138. public void setResourceAdaptorContext(ResourceAdaptorContext context) {
  139. this.raContext = context;
  140. this.tracer = context.getTracer("IsupResourceAdaptor");
  141. this.sleeEndpoint = context.getSleeEndpoint();
  142. this.eventLookupFacility = context.getEventLookupFacility();
  143. this.eventTypeCache = new FireableEventTypeCache(tracer);
  144. this.eventTypeFilter = new FireableEventTypeFilter();
  145. }
  146. public void unsetResourceAdaptorContext() {
  147. this.tracer = null;
  148. this.raContext = null;
  149. this.sleeEndpoint = null;
  150. this.eventLookupFacility = null;
  151. this.eventTypeCache = null;
  152. this.eventTypeFilter = null;
  153. }
  154. public void raConfigure(ConfigProperties configProperties) {
  155. try {
  156. if (tracer.isInfoEnabled()) {
  157. tracer.info("Configuring ISUPRA: " + this.raContext.getEntityName());
  158. }
  159. this.isupJndi = (String) configProperties.getProperty(CONF_ISUP_JNDI).getValue();
  160. } catch (Exception e) {
  161. tracer.severe("Configuring of ISUP RA failed ", e);
  162. }
  163. this.raProvider = new RAISUPProviderImpl();
  164. }
  165. public void raUnconfigure() {
  166. }
  167. public void raActive() {
  168. try {
  169. InitialContext ic = new InitialContext();
  170. this.isupProvider = (ISUPProvider) ic.lookup(this.isupJndi);
  171. tracer.info("Sucssefully connected to ISUP service[" + this.isupJndi + "]");
  172. this.isupProvider.addListener(this);
  173. } catch (Exception e) {
  174. // TODO Auto-generated catch block
  175. this.tracer.severe("Failed to activate ISUP RA ", e);
  176. }
  177. }
  178. public void raStopping() {
  179. throw new UnsupportedOperationException("Not supported yet.");
  180. }
  181. public void raInactive() {
  182. throw new UnsupportedOperationException("Not supported yet.");
  183. }
  184. public void raVerifyConfiguration(ConfigProperties configProperties) throws InvalidConfigurationException {
  185. try {
  186. if (tracer.isInfoEnabled()) {
  187. tracer.info("Verifying configuring ISUPA: " + this.raContext.getEntityName());
  188. }
  189. this.isupJndi = (String) configProperties.getProperty(CONF_ISUP_JNDI).getValue();
  190. if (this.isupJndi == null) {
  191. throw new InvalidConfigurationException("ISUP JNDI lookup name cannot be null");
  192. }
  193. } catch (Exception e) {
  194. throw new InvalidConfigurationException("Failed to test configuration options!", e);
  195. }
  196. }
  197. public void raConfigurationUpdate(ConfigProperties arg0) {
  198. throw new UnsupportedOperationException("Not supported yet.");
  199. }
  200. public Object getResourceAdaptorInterface(String arg0) {
  201. return this.raProvider;
  202. }
  203. public Marshaler getMarshaler() {
  204. return null;
  205. }
  206. public void serviceActive(ReceivableService receivableService) {
  207. eventTypeFilter.serviceActive(receivableService);
  208. }
  209. public void serviceStopping(ReceivableService receivableService) {
  210. eventTypeFilter.serviceStopping(receivableService);
  211. }
  212. public void serviceInactive(ReceivableService receivableService) {
  213. eventTypeFilter.serviceInactive(receivableService);
  214. }
  215. public void queryLiveness(ActivityHandle arg0) {
  216. //throw new UnsupportedOperationException("Not supported yet.");
  217. }
  218. public Object getActivity(ActivityHandle key) {
  219. return this.activities.get(key);
  220. }
  221. public ActivityHandle getActivityHandle(Object act) {
  222. if(act instanceof CircuitActivity)
  223. {
  224. CircuitActivity activity = (CircuitActivity) act;
  225. return createActivityHandle(activity);
  226. }
  227. return null;
  228. }
  229. public void administrativeRemove(ActivityHandle handle) {
  230. if(this.activities.containsKey(handle))
  231. {
  232. //this.activities.remove(handle);
  233. }
  234. }
  235. public void eventProcessingSuccessful(ActivityHandle arg0, FireableEventType arg1, Object arg2, Address arg3, ReceivableService arg4, int arg5) {
  236. //throw new UnsupportedOperationException("Not supported yet.");
  237. }
  238. public void eventProcessingFailed(ActivityHandle arg0, FireableEventType arg1, Object arg2, Address arg3, ReceivableService arg4, int arg5, FailureReason arg6) {
  239. //throw new UnsupportedOperationException("Not supported yet.");
  240. }
  241. public void eventUnreferenced(ActivityHandle arg0, FireableEventType arg1, Object arg2, Address arg3, ReceivableService arg4, int arg5) {
  242. //throw new UnsupportedOperationException("Not supported yet.");
  243. }
  244. public void activityEnded(ActivityHandle handle) {
  245. //throw new UnsupportedOperationException("Not supported yet.");
  246. this.activities.remove(handle);
  247. }
  248. public void activityUnreferenced(ActivityHandle handle) {
  249. //throw new UnsupportedOperationException("Not supported yet.");
  250. }
  251. protected void fireEvent(FireableEventType eventType, Object activity, Object event) {
  252. final ActivityHandle handle = this.getActivityHandle(activity);
  253. //TODO insert global title.
  254. //this causes failure
  255. // final Address address = new Address(AddressPlan.GT, "");
  256. try {
  257. sleeEndpoint.fireEvent(handle, eventType, event, null, null, EVENT_FLAGS);
  258. tracer.info("Fired event: " + eventType);
  259. } catch (Throwable e) {
  260. tracer.severe("Failed to fire event", e);
  261. }
  262. }
  263. //////////////////
  264. // Some private //
  265. //////////////////
  266. private ActivityHandle createActivityHandle(CircuitActivity ca)
  267. {
  268. long txKey = ca.getTransactionKey();
  269. return new ISUPActivityHandle(txKey);
  270. }
  271. ///////////////////////////
  272. // ISUP Listener methods //
  273. ///////////////////////////
  274. /* (non-Javadoc)
  275. * @see org.mobicents.protocols.ss7.isup.ISUPListener#onMessage(org.mobicents.protocols.ss7.isup.message.ISUPMessage)
  276. */
  277. public void onEvent(ISUPEvent event) {
  278. if(tracer.isInfoEnabled())
  279. {
  280. tracer.info("Received Message, code: "+event.getMessage().getMessageType().getCode());
  281. }
  282. //we have activity, now:
  283. // 1. get handle
  284. // 2. get event type
  285. // 3. fire
  286. //ActivityHandle handle = createActivityHandle(tx);
  287. String eventName = null;
  288. switch(event.getMessage().getMessageType().getCode())
  289. {
  290. case AnswerMessage.MESSAGE_CODE:
  291. eventName = "ANSWER";
  292. break;
  293. case ApplicationTransportMessage.MESSAGE_CODE:
  294. eventName = "APPLICATION_TRANSPORT";
  295. break;
  296. case AddressCompleteMessage.MESSAGE_CODE:
  297. eventName = "ADDRESS_COMPLETE";
  298. break;
  299. case BlockingMessage.MESSAGE_CODE:
  300. eventName = "BLOCKING";
  301. break;
  302. case BlockingAckMessage.MESSAGE_CODE:
  303. eventName = "BLOCKING_ACK";
  304. break;
  305. case CallProgressMessage.MESSAGE_CODE:
  306. eventName = "CALL_PROGRESS";
  307. break;
  308. case ChargeInformationMessage.MESSAGE_CODE:
  309. eventName = "CHARGE_INFORMATION";
  310. break;
  311. case CircuitGroupBlockingMessage.MESSAGE_CODE:
  312. eventName = "CIRCUIT_GROUP_BLOCKING";
  313. break;
  314. case CircuitGroupBlockingAckMessage.MESSAGE_CODE:
  315. eventName = "CIRCUIT_GROUP_BLOCKING_ACK";
  316. break;
  317. case CircuitGroupQueryMessage.MESSAGE_CODE:
  318. eventName = "CIRCUIT_GROUP_QUERY";
  319. break;
  320. case CircuitGroupQueryResponseMessage.MESSAGE_CODE:
  321. eventName = "CIRCUIT_GROUP_QUERY_RESPONSE";
  322. break;
  323. case CircuitGroupResetMessage.MESSAGE_CODE:
  324. eventName = "CIRCUIT_GROUP_RESET";
  325. break;
  326. case CircuitGroupResetAckMessage.MESSAGE_CODE:
  327. eventName = "CIRCUIT_GROUP_RESET_ACK";
  328. break;
  329. case CircuitGroupUnblockingMessage.MESSAGE_CODE:
  330. eventName = "CIRCUIT_GROUP_UNBLOCKING";
  331. break;
  332. case CircuitGroupUnblockingAckMessage.MESSAGE_CODE:
  333. eventName = "CIRCUIT_GROUP_UNBLOCKING_ACK";
  334. break;
  335. case ConnectMessage.MESSAGE_CODE:
  336. eventName = "CONNECT";
  337. break;
  338. case ContinuityCheckRequestMessage.MESSAGE_CODE:
  339. eventName = "CONTINUITY_CHECK_REQUEST";
  340. break;
  341. case ContinuityMessage.MESSAGE_CODE:
  342. eventName = "CONTINUITY";
  343. break;
  344. case FacilityAcceptedMessage.MESSAGE_CODE:
  345. eventName = "FACILITY_ACCPETED";
  346. break;
  347. case FacilityRejectedMessage.MESSAGE_CODE:
  348. eventName = "FACILITY_REJECTED";
  349. break;
  350. case ForwardTransferMessage.MESSAGE_CODE:
  351. eventName = "FORWARD_TRANSFER";
  352. break;
  353. case IdentificationRequestMessage.MESSAGE_CODE:
  354. eventName = "IDENTIFICATION_REQUEST";
  355. break;
  356. case IdentificationResponseMessage.MESSAGE_CODE:
  357. eventName = "IDENTIFICATION_RESPONSE";
  358. break;
  359. case InitialAddressMessage.MESSAGE_CODE:
  360. eventName = "INITIAL_ADDRESS_MESSAGE";
  361. break;
  362. case LoopPreventionMessage.MESSAGE_CODE:
  363. eventName = "LOOP_PREVENTION";
  364. break;
  365. case LoopbackAckMessage.MESSAGE_CODE:
  366. eventName = "LOOPBACK_ACK";
  367. break;
  368. case NetworkResourceManagementMessage.MESSAGE_CODE:
  369. eventName = "NETWORK_RESOURCE_MANAGEMENT";
  370. break;
  371. case OverloadMessage.MESSAGE_CODE:
  372. eventName = "OVERLOAD";
  373. break;
  374. case PassAlongMessage.MESSAGE_CODE:
  375. eventName = "PASS_ALONG";
  376. break;
  377. case PreReleaseInformationMessage.MESSAGE_CODE:
  378. eventName = "PRERELEASE_INFORMATION";
  379. break;
  380. case ReleaseCompleteMessage.MESSAGE_CODE:
  381. eventName = "RELEASE_COMPLETE";
  382. break;
  383. case ReleaseMessage.MESSAGE_CODE:
  384. eventName = "RELEASE";
  385. break;
  386. case ResetCircuitMessage.MESSAGE_CODE:
  387. eventName = "RESET_CIRCUIT";
  388. break;
  389. case ResumeMessage.MESSAGE_CODE:
  390. eventName = "RESUME";
  391. break;
  392. case SubsequentAddressMessage.MESSAGE_CODE:
  393. eventName = "SUBSEQUENT_ADDRESS";
  394. break;
  395. case SubsequentDirectoryNumberMessage.MESSAGE_CODE:
  396. eventName = "SUBSEQUENT_DIRECTORY_NUMBER";
  397. break;
  398. case SuspendMessage.MESSAGE_CODE:
  399. eventName = "SUSPEND";
  400. break;
  401. case UnblockingMessage.MESSAGE_CODE:
  402. eventName = "UNBLOCKING";
  403. break;
  404. case UnblockingAckMessage.MESSAGE_CODE:
  405. eventName = "UNBLOCKING_ACK";
  406. break;
  407. case UnequippedCICMessage.MESSAGE_CODE:
  408. eventName = "UNEQUIPPED_CIC";
  409. break;
  410. case User2UserInformationMessage.MESSAGE_CODE:
  411. eventName = "USER_TO_USER_INFORMATION";
  412. break;
  413. case UserPartAvailableMessage.MESSAGE_CODE:
  414. eventName = "USER_PART_AVAILABLE";
  415. break;
  416. case UserPartTestMessage.MESSAGE_CODE:
  417. eventName = "USER_PART_TEST";
  418. break;
  419. default:
  420. tracer.severe("Received unkown event code: "+event.getMessage().getMessageType().getCode());
  421. return;
  422. }
  423. final FireableEventType eventType = eventTypeCache.getEventType(eventLookupFacility, eventName);
  424. //if there is no TX, lets create STX
  425. long tx=CircuitActivity.generateTransactionKey(event.getMessage().getCircuitIdentificationCode().getCIC(),event.getDpc());
  426. CircuitActivity ca = (CircuitActivity)getActivity(new ISUPActivityHandle(tx));
  427. if(ca == null)
  428. {
  429. if (eventTypeFilter.filterInitialEvent(eventType)) {
  430. tracer.info("event " + eventName + " filtered");
  431. ConfusionMessage cm=this.raProvider.getMessageFactory().createCNF(event.getMessage().getCircuitIdentificationCode().getCIC());
  432. CauseIndicators ci=this.raProvider.getParameterFactory().createCauseIndicators();
  433. ci.setLocation(CauseIndicators._LOCATION_NETWORK_BEYOND_IP);
  434. ci.setCauseValue(CauseIndicators._CV_INVALID_MESSAGE_UNSPECIFIED);
  435. cm.setCauseIndicators(ci);
  436. try
  437. {
  438. this.raProvider.sendMessage(cm,event.getDpc());
  439. }
  440. catch(Exception ex)
  441. {}
  442. return;
  443. }
  444. //FIXME: determine in Qs if there is error msg to be sent.... can be extremly complciated since there is 40+ messages
  445. try {
  446. ca = this.raProvider.createCircuitActivity(event.getMessage(),event.getDpc());
  447. } catch (ActivityAlreadyExistsException e) {
  448. // TODO Auto-generated catch block
  449. e.printStackTrace();
  450. } catch (IllegalArgumentException e) {
  451. // TODO Auto-generated catch block
  452. e.printStackTrace();
  453. } catch (NullPointerException e) {
  454. // TODO Auto-generated catch block
  455. e.printStackTrace();
  456. } catch (IllegalStateException e) {
  457. // TODO Auto-generated catch block
  458. e.printStackTrace();
  459. } catch (SLEEException e) {
  460. // TODO Auto-generated catch block
  461. e.printStackTrace();
  462. } catch (StartActivityException e) {
  463. // TODO Auto-generated catch block
  464. e.printStackTrace();
  465. }
  466. }
  467. else
  468. {
  469. //may be also initial event , for example for blocking
  470. if (eventTypeFilter.filterEvent(eventType) && eventTypeFilter.filterInitialEvent(eventType)) {
  471. tracer.info("event " + eventName + " filtered");
  472. ConfusionMessage cm=this.raProvider.getMessageFactory().createCNF(event.getMessage().getCircuitIdentificationCode().getCIC());
  473. CauseIndicators ci=this.raProvider.getParameterFactory().createCauseIndicators();
  474. ci.setLocation(CauseIndicators._LOCATION_NETWORK_BEYOND_IP);
  475. ci.setCauseValue(CauseIndicators._CV_INVALID_MESSAGE_UNSPECIFIED);
  476. cm.setCauseIndicators(ci);
  477. try
  478. {
  479. this.raProvider.sendMessage(cm,event.getDpc());
  480. }
  481. catch(Exception ex)
  482. {}
  483. return;
  484. }
  485. }
  486. this.fireEvent(eventType, ca, event.getMessage());
  487. }
  488. public void onTimeout(ISUPTimeoutEvent event) {
  489. ActivityHandle handle=new ISUPActivityHandle(CircuitActivity.generateTransactionKey(event.getMessage().getCircuitIdentificationCode().getCIC(),event.getDpc()));
  490. if(this.activities.containsKey(handle))
  491. {
  492. TimeoutEvent te = new TimeoutEvent(event.getMessage(),event.getTimerId());
  493. final FireableEventType eventType = eventTypeCache.getEventType(eventLookupFacility, "TRANSACTION_TIMEOUT");
  494. if (eventTypeFilter.filterEvent(eventType)) {
  495. tracer.info("event TRANSACTION_TIMEOUT filtered");
  496. return;
  497. }
  498. this.fireEvent(eventType, getActivity(handle), te);
  499. }
  500. }
  501. /* (non-Javadoc)
  502. * @see org.mobicents.protocols.ss7.isup.ISUPListener#onTransportDown()
  503. */
  504. public void onTransportDown() {
  505. this.transportUp = false;
  506. }
  507. /* (non-Javadoc)
  508. * @see org.mobicents.protocols.ss7.isup.ISUPListener#onTransportUp()
  509. */
  510. public void onTransportUp() {
  511. // TODO Auto-generated method stub
  512. this.transportUp = true;
  513. }
  514. ///////////////////////
  515. // RA Provider Class //
  516. ///////////////////////
  517. private class RAISUPProviderImpl implements RAISUPProvider
  518. {
  519. public CircuitActivity createCircuitActivity(ISUPMessage arg0,int dpc) throws IllegalArgumentException, ActivityAlreadyExistsException,
  520. NullPointerException, IllegalStateException, SLEEException, StartActivityException {
  521. ActivityHandle handle=new ISUPActivityHandle(CircuitActivity.generateTransactionKey(arg0.getCircuitIdentificationCode().getCIC(),dpc));
  522. if(activities.containsKey(handle))
  523. throw new ActivityAlreadyExistsException("Circuit activity already exists");
  524. CircuitActivity activity = new CircuitActivity(arg0,dpc,this);
  525. handle = createActivityHandle(activity);
  526. sleeEndpoint.startActivity(handle, activity,ACTIVITY_FLAGS);
  527. activities.putIfAbsent(handle,activity);
  528. return activity;
  529. }
  530. public ISUPMessageFactory getMessageFactory() {
  531. return isupProvider.getMessageFactory();
  532. }
  533. public ISUPParameterFactory getParameterFactory() {
  534. return isupProvider.getParameterFactory();
  535. }
  536. public void sendMessage(ISUPMessage arg0,int dpc) throws ParameterException, IOException {
  537. isupProvider.sendMessage(arg0,dpc);
  538. }
  539. public void notifyBlockedChannel(int cic, int dpc)
  540. {
  541. ActivityHandle handle=new ISUPActivityHandle(CircuitActivity.generateTransactionKey(cic,dpc));
  542. if(activities.containsKey(handle))
  543. {
  544. BlockedEvent be = new BlockedEvent(cic,dpc);
  545. final FireableEventType eventType = eventTypeCache.getEventType(eventLookupFacility, "BLOCKED");
  546. if (eventTypeFilter.filterEvent(eventType)) {
  547. tracer.info("event BLOCKED filtered");
  548. return;
  549. }
  550. fireEvent(eventType, getActivity(handle), be);
  551. }
  552. }
  553. public void notifyResetChannel(int cic, int dpc)
  554. {
  555. ActivityHandle handle=new ISUPActivityHandle(CircuitActivity.generateTransactionKey(cic,dpc));
  556. if(activities.containsKey(handle))
  557. {
  558. BlockedEvent be = new BlockedEvent(cic,dpc);
  559. final FireableEventType eventType = eventTypeCache.getEventType(eventLookupFacility, "RESET");
  560. if (eventTypeFilter.filterEvent(eventType)) {
  561. tracer.info("event RESET filtered");
  562. return;
  563. }
  564. fireEvent(eventType, getActivity(handle), be);
  565. }
  566. }
  567. public void cancelTimer(int cic, int dpc, int timerId)
  568. {
  569. isupProvider.cancelTimer(cic,dpc,timerId);
  570. }
  571. public void endActivity(CircuitActivity ac)
  572. {
  573. isupProvider.cancelAllTimers(ac.getCIC(),ac.getDPC());
  574. ActivityHandle handle=getActivityHandle(ac);
  575. sleeEndpoint.endActivity(handle);
  576. activityEnded(handle);
  577. }
  578. /* (non-Javadoc)
  579. * @see org.mobicents.slee.resources.ss7.isup.ratype.RAISUPProvider#isTransportUp()
  580. */
  581. public boolean isTransportUp() {
  582. return transportUp;
  583. }
  584. }
  585. }