use of org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl in project jain-slee.diameter by RestComm.
the class DiameterShClientResourceAdaptor method raActive.
public void raActive() {
if (tracer.isFineEnabled()) {
tracer.fine("Diameter ShClient RA :: raActive.");
}
try {
if (tracer.isInfoEnabled()) {
tracer.info("Activating Diameter ShClient 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>();
initStack();
// Initialize activity mgmt
initActivitiesMgmt();
// Initialize factories
this.baseAvpFactory = new DiameterAvpFactoryImpl();
this.shAvpFactory = new DiameterShAvpFactoryImpl(baseAvpFactory);
this.shClientMessageFactory = new ShClientMessageFactoryImpl(stack);
// Set the first configured Application-Id as default for message factory
ApplicationId firstAppId = authApplicationIds.get(0);
((ShClientMessageFactoryImpl) this.shClientMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
// Setup session factories
this.sessionFactory = this.stack.getSessionFactory();
((ISessionFactory) sessionFactory).registerAppFacory(ClientShSession.class, new ShClientSessionFactory(this, this.sessionFactory));
} catch (Exception e) {
tracer.severe("Error Activating Diameter ShClient RA Entity", e);
}
}
use of org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method raActive.
// More life cycle methods ----------------------------------------------
public void raActive() {
if (tracer.isFineEnabled()) {
tracer.fine("Diameter ShServer RA :: raActive.");
}
try {
if (tracer.isInfoEnabled()) {
tracer.info("Activating Diameter ShServer 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 stack
initStack();
// Initialize activities mgmt
initActivitiesMgmt();
// Initialize factories
this.baseAvpFactory = new DiameterAvpFactoryImpl();
this.shAvpFactory = new DiameterShAvpFactoryImpl(baseAvpFactory);
this.shServerMessageFactory = new ShServerMessageFactoryImpl(stack);
// Set the first configured Application-Id as default for message factory
ApplicationId firstAppId = authApplicationIds.get(0);
((ShServerMessageFactoryImpl) this.shServerMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
// Setup session factories
this.sessionFactory = this.stack.getSessionFactory();
((ISessionFactory) sessionFactory).registerAppFacory(ServerShSession.class, new ShServerSessionFactory(sessionFactory, this));
} catch (Exception e) {
tracer.severe("Error Activating Diameter ShServer RA Entity", e);
}
}
use of org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method initStack.
// Private Methods -----------------------------------------------------
/**
* Initializes the RA Diameter Stack.
*
* @throws Exception
*/
private synchronized void initStack() throws Exception {
// Register in the Mux as app listener.
this.diameterMux.registerListener(this, (ApplicationId[]) authApplicationIds.toArray(new ApplicationId[authApplicationIds.size()]));
// Get the stack (should not mess with)
this.stack = this.diameterMux.getStack();
this.messageTimeout = stack.getMetaData().getConfiguration().getLongValue(MessageTimeOut.ordinal(), (Long) MessageTimeOut.defValue());
this.raProvider = new ShServerProviderImpl(this);
this.shAvpFactory = new DiameterShAvpFactoryImpl(this.baseAvpFactory);
if (tracer.isInfoEnabled()) {
tracer.info("Diameter ShServer RA :: Successfully initialized stack.");
}
}
use of org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl in project jain-slee.diameter by RestComm.
the class ShClientActivityAnswerCreationTest method testShClientActivityAnswerCreation.
@Test
public void testShClientActivityAnswerCreation() throws Exception {
ClientShSession session = new ShClientSessionImpl(new ShClientSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ClientShSessionListenerImpl());
PushNotificationRequest pnr = new PushNotificationRequestImpl(stack.getSessionFactory().getNewSession().createRequest(PushNotificationRequest.commandCode, SH_APP_ID, "mobicents.org", "hss.mobicents"));
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(pnr);
ShClientSubscriptionActivityImpl activity = new ShClientSubscriptionActivityImpl(new ShClientMessageFactoryImpl(session.getSessions().get(0), stack), new DiameterShAvpFactoryImpl(diameterAvpFactory), session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Aggregations