Search in sources :

Example 1 with DiameterShAvpFactoryImpl

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);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) OverloadException(org.jdiameter.api.OverloadException) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) RouteException(org.jdiameter.api.RouteException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)

Example 2 with DiameterShAvpFactoryImpl

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);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) ShServerSessionFactory(org.mobicents.slee.resource.diameter.sh.server.handlers.ShServerSessionFactory) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) AvpDataException(org.jdiameter.api.AvpDataException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)

Example 3 with DiameterShAvpFactoryImpl

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.");
    }
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)

Example 4 with DiameterShAvpFactoryImpl

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);
}
Also used : PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ClientShSession(org.jdiameter.api.sh.ClientShSession) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientSessionImpl(org.jdiameter.client.impl.app.sh.ShClientSessionImpl) ShClientSessionDataLocalImpl(org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) ShClientSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientSubscriptionActivityImpl) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

DiameterShAvpFactoryImpl (org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)4 ApplicationId (org.jdiameter.api.ApplicationId)3 IOException (java.io.IOException)2 ObjectName (javax.management.ObjectName)2 OperationNotSupportedException (javax.naming.OperationNotSupportedException)2 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)2 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)2 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)2 AvpDataException (org.jdiameter.api.AvpDataException)2 ISessionFactory (org.jdiameter.client.api.ISessionFactory)2 DiameterStackMultiplexerMBean (org.mobicents.diameter.stack.DiameterStackMultiplexerMBean)2 DiameterAvpFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl)2 ArrayList (java.util.ArrayList)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)1 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)1 InternalException (org.jdiameter.api.InternalException)1 OverloadException (org.jdiameter.api.OverloadException)1 RouteException (org.jdiameter.api.RouteException)1 ClientShSession (org.jdiameter.api.sh.ClientShSession)1