use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterRxResourceAdaptor method raActive.
/**
* {@inheritDoc}
*/
@Override
public void raActive() {
if (tracer.isFineEnabled()) {
tracer.fine("Diameter Rx RA :: raActive.");
}
try {
if (tracer.isInfoEnabled()) {
tracer.info("Activating Diameter Rx RA Entity");
}
this.diameterMultiplexerObjectName = new ObjectName("diameter.mobicents:service=DiameterStackMultiplexer");
Object object = null;
if (ManagementFactory.getPlatformMBeanServer().isRegistered(this.diameterMultiplexerObjectName)) {
// trying to get via MBeanServer
object = ManagementFactory.getPlatformMBeanServer().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via Platform MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
} else {
// trying to get via locateJBoss
object = MBeanServerLocator.locateJBoss().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via JBoss MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
}
if (object != null && object instanceof DiameterStackMultiplexerMBean) {
this.diameterMux = (DiameterStackMultiplexerMBean) object;
}
// Initialize the protocol stack
initStack();
// Initialize activities mgmt
initActivitiesMgmt();
// Initialize factories
this.baseAvpFactory = new DiameterAvpFactoryImpl();
this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
this.rxAvpFactory = new RxAvpFactoryImpl(baseAvpFactory);
this.rxMessageFactory = new RxMessageFactoryImpl(baseMessageFactory, null, stack);
// Set the first configured Application-Id as default for message factory
ApplicationId firstAppId = authApplicationIds.get(0);
((RxMessageFactoryImpl) this.rxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
this.sessionFactory = this.stack.getSessionFactory();
this.rxSessionFactory = new RxSessionFactory(this, sessionFactory);
// Register Rx App Session Factories
((ISessionFactory) sessionFactory).registerAppFacory(ServerRxSession.class, this.rxSessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ClientRxSession.class, this.rxSessionFactory);
} catch (Exception e) {
tracer.severe("Error Activating Diameter Rx RA Entity", e);
}
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl method getApplicationId.
private ApplicationId getApplicationId(DiameterAvp[] avps) {
ApplicationId applicationId = null;
long vendorId = 0L;
// Try to get Application-Id from Message AVPs
if (avps != null) {
for (DiameterAvp avp : avps) {
if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
vendorId = avp.intValue();
}
if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
break;
}
if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
break;
} else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
break;
}
}
}
return applicationId;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterRfResourceAdaptor method raActive.
public void raActive() {
if (tracer.isFineEnabled()) {
tracer.fine("Diameter Rf RA :: raActive.");
}
try {
if (tracer.isInfoEnabled()) {
tracer.info("Activating Diameter Rf RA Entity");
}
this.diameterMultiplexerObjectName = new ObjectName("diameter.mobicents:service=DiameterStackMultiplexer");
Object object = null;
if (ManagementFactory.getPlatformMBeanServer().isRegistered(this.diameterMultiplexerObjectName)) {
// trying to get via MBeanServer
object = ManagementFactory.getPlatformMBeanServer().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via Platform MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
} else {
// trying to get via locateJBoss
object = MBeanServerLocator.locateJBoss().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
if (tracer.isInfoEnabled()) {
tracer.info("Trying to get via JBoss MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
}
}
if (object != null && object instanceof DiameterStackMultiplexerMBean) {
this.diameterMux = (DiameterStackMultiplexerMBean) object;
}
// /this.activities = new ConcurrentHashMap<ActivityHandle, DiameterActivity>();
// Initialize the protocol stack
initStack();
// Init activities mgmt
initActivitiesMgmt();
// Initialize factories
this.baseAvpFactory = new DiameterAvpFactoryImpl();
this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
this.rfAvpFactory = new RfAvpFactoryImpl();
this.rfMessageFactory = new RfMessageFactoryImpl(baseMessageFactory, null, stack);
// Set the first configured Application-Id as default for message factory
ApplicationId firstAppId = acctApplicationIds.get(0);
((RfMessageFactoryImpl) this.rfMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAcctAppId());
// Register Accounting App Session Factories
this.sessionFactory = this.stack.getSessionFactory();
this.rfSessionFactory = new RfSessionFactory(this, sessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ServerRfSession.class, rfSessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ClientRfSession.class, rfSessionFactory);
} catch (Exception e) {
tracer.severe("Error Activating Diameter Rf RA Entity", e);
}
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class RfFactoriesTest method testMessageFactoryApplicationIdChangeACR.
@Test
public void testMessageFactoryApplicationIdChangeACR() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Rf is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
RfAccountingRequest originalACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACR);
// now we switch..
originalACR = null;
isVendor = !isVendor;
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
RfAccountingRequest changedACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACR);
// revert back to default
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class RfFactoriesTest method testServerSessionApplicationIdChangeACA.
@Test
public void testServerSessionApplicationIdChangeACA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Rf is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
((RfServerSessionActivityImpl) rfServerSession).fetchSessionData(acr, true);
RfAccountingAnswer originalACA = rfServerSession.createRfAccountingAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACA);
// now we switch..
originalACA = null;
isVendor = !isVendor;
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
RfAccountingAnswer changedACA = rfServerSession.createRfAccountingAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
changedACA = rfServerSession.createRfAccountingAnswer(acr);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
// revert back to default
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Aggregations