Search in sources :

Example 11 with ISessionFactory

use of org.jdiameter.client.api.ISessionFactory in project jain-slee.diameter by RestComm.

the class DiameterGxResourceAdaptor method raActive.

/**
 * {@inheritDoc}
 */
@Override
public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Gx RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Gx 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.gxAvpFactory = new GxAvpFactoryImpl(baseAvpFactory);
        this.gxMessageFactory = new GxMessageFactoryImpl(baseMessageFactory, null, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((GxMessageFactoryImpl) this.gxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        this.sessionFactory = this.stack.getSessionFactory();
        this.gxSessionFactory = new GxSessionFactory(this, sessionFactory, defaultDirectDebitingFailureHandling, defaultCreditControlFailureHandling, defaultValidityTime, defaultTxTimerValue);
        // Register Gx App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerGxSession.class, this.gxSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientGxSession.class, this.gxSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Gx RA Entity", e);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) GxSessionFactory(org.mobicents.slee.resource.diameter.gx.handlers.GxSessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) AvpDataException(org.jdiameter.api.AvpDataException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Example 12 with ISessionFactory

use of org.jdiameter.client.api.ISessionFactory in project jain-slee.diameter by RestComm.

the class DiameterGqResourceAdaptor method raActive.

@Override
public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Gq RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Gq 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();
        // Initialize activities mgmt
        initActivitiesMgmt();
        // Initialize factories
        this.baseAvpFactory = new DiameterAvpFactoryImpl();
        this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
        this.gqAvpFactory = new GqAvpFactoryImpl(baseAvpFactory);
        this.gqMessageFactory = new GqMessageFactoryImpl(baseMessageFactory, null, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((GqMessageFactoryImpl) this.gqMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        this.sessionFactory = this.stack.getSessionFactory();
        this.gqSessionFactory = new GqSessionFactory(this, sessionFactory);
        // Register Gq App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(GqServerSession.class, this.gqSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(GqClientSession.class, this.gqSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Gq RA Entity", e);
    }
}
Also used : DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) DiameterAvpFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) GqSessionFactory(org.mobicents.slee.resource.diameter.gq.handlers.GqSessionFactory) AvpDataException(org.jdiameter.api.AvpDataException) 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)

Aggregations

ObjectName (javax.management.ObjectName)12 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)12 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)12 ISessionFactory (org.jdiameter.client.api.ISessionFactory)12 DiameterStackMultiplexerMBean (org.mobicents.diameter.stack.DiameterStackMultiplexerMBean)12 ApplicationId (org.jdiameter.api.ApplicationId)11 AvpDataException (org.jdiameter.api.AvpDataException)11 DiameterAvpFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl)11 OperationNotSupportedException (javax.naming.OperationNotSupportedException)9 IOException (java.io.IOException)7 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)7 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)6 InternalException (org.jdiameter.api.InternalException)6 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)3 DiameterShAvpFactoryImpl (org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl)2 InvalidTransactionException (javax.transaction.InvalidTransactionException)1 SystemException (javax.transaction.SystemException)1 OverloadException (org.jdiameter.api.OverloadException)1 RawSession (org.jdiameter.api.RawSession)1 RouteException (org.jdiameter.api.RouteException)1