Search in sources :

Example 6 with ISessionFactory

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

the class DiameterS13ResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter S13 RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter S13 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.s13AvpFactory = new S13AVPFactoryImpl(baseAvpFactory);
        this.s13MessageFactory = new S13MessageFactoryImpl(stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((S13MessageFactoryImpl) this.s13MessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.s13SessionFactory = new S13SessionFactory(this, messageTimeout, sessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerS13Session.class, s13SessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientS13Session.class, s13SessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter S13 RA Entity", e);
    }
}
Also used : S13SessionFactory(org.mobicents.slee.resource.diameter.s13.handlers.S13SessionFactory) 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) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Example 7 with ISessionFactory

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

the class DiameterCxDxResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Cx/Dx RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Cx/Dx 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.cxdxAvpFactory = new CxDxAVPFactoryImpl(baseAvpFactory);
        this.cxdxMessageFactory = new CxDxMessageFactoryImpl(baseMessageFactory, stack);
        // Set the first configured Application-Id as default for message factory
        ApplicationId firstAppId = authApplicationIds.get(0);
        ((CxDxMessageFactoryImpl) this.cxdxMessageFactory).setApplicationId(firstAppId.getVendorId(), firstAppId.getAuthAppId());
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.cxdxSessionFactory = new CxDxSessionFactory(this, messageTimeout, sessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerCxDxSession.class, cxdxSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientCxDxSession.class, cxdxSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Cx/Dx 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) CxDxSessionFactory(org.mobicents.slee.resource.diameter.cxdx.handlers.CxDxSessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Example 8 with ISessionFactory

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

the class DiameterCCAResourceAdaptor method raActive.

// Lifecycle again
public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter CCA RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter CCA 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 stack
        initStack();
        // Initialize activities mgmt
        initActivitiesMgmt();
        // Initialize factories
        this.baseAvpFactory = new DiameterAvpFactoryImpl();
        this.ccaAvpFactory = new CreditControlAVPFactoryImpl(baseAvpFactory);
        this.baseMessageFactory = new DiameterMessageFactoryImpl(stack);
        this.ccaMessageFactory = new CreditControlMessageFactoryImpl(baseMessageFactory, null, stack, ccaAvpFactory);
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.ccaSessionFactory = new CreditControlSessionFactory(sessionFactory, this, defaultDirectDebitingFailureHandling, defaultCreditControlFailureHandling, defaultValidityTime, defaultTxTimerValue);
        // Register CCA App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerCCASession.class, this.ccaSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientCCASession.class, this.ccaSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter CCA RA Entity", e);
        // ??
        throw new RuntimeException(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) CreditControlSessionFactory(org.mobicents.slee.resource.diameter.cca.handlers.CreditControlSessionFactory) InvalidTransactionException(javax.transaction.InvalidTransactionException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) SystemException(javax.transaction.SystemException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName)

Example 9 with ISessionFactory

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

the class DiameterBaseResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Base RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Base 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 activity storage
        initActivitiesMgmt();
        // Initialize factories
        this.messageFactory = new DiameterMessageFactoryImpl(stack);
        this.avpFactory = new DiameterAvpFactoryImpl();
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.accSessionFactory = AccountingSessionFactory.INSTANCE;
        this.accSessionFactory.registerListener(this, messageTimeout, sessionFactory);
        this.authSessionFactory = new AuthorizationSessionFactory(this, messageTimeout, sessionFactory);
        this.proxySessionFactory = new SessionFactory() {

            public <T extends AppSession> T getNewAppSession(ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException {
                return (T) sessionFactory.getNewAppSession(applicationId, userSession);
            }

            public <T extends AppSession> T getNewAppSession(String sessionId, ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException {
                return (T) sessionFactory.getNewAppSession(sessionId, applicationId, userSession);
            }

            public RawSession getNewRawSession() throws InternalException {
                try {
                    return stack.getSessionFactory().getNewRawSession();
                } catch (IllegalDiameterStateException e) {
                    tracer.severe("Failure while obtaining Session Factory for new Raw Session.", e);
                    return null;
                }
            }

            public Session getNewSession() throws InternalException {
                Session session = sessionFactory.getNewSession();
                sessionCreated(session);
                return session;
            }

            public Session getNewSession(String sessionId) throws InternalException {
                Session session = sessionFactory.getNewSession(sessionId);
                sessionCreated(session);
                return session;
            }

            public String getSessionId() {
                return sessionFactory.getSessionId();
            }

            public String getSessionId(String customPart) {
                return sessionFactory.getSessionId(customPart);
            }
        };
        // Register Accounting App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerAccSession.class, accSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientAccSession.class, accSessionFactory);
        // Register Authorization App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerAuthSession.class, authSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientAuthSession.class, authSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Base RA Entity", e);
    }
}
Also used : AccountingSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AccountingSessionFactory) AuthorizationSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AuthorizationSessionFactory) SessionFactory(org.jdiameter.api.SessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) AuthorizationSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AuthorizationSessionFactory) RawSession(org.jdiameter.api.RawSession) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) 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) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) ServerAuthSession(org.jdiameter.api.auth.ServerAuthSession) ClientAuthSession(org.jdiameter.api.auth.ClientAuthSession) AppSession(org.jdiameter.api.app.AppSession) RawSession(org.jdiameter.api.RawSession) ClientAccSession(org.jdiameter.api.acc.ClientAccSession) Session(org.jdiameter.api.Session) ServerAccSession(org.jdiameter.api.acc.ServerAccSession)

Example 10 with ISessionFactory

use of org.jdiameter.client.api.ISessionFactory 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)

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