Search in sources :

Example 6 with AppSession

use of org.jdiameter.api.app.AppSession in project jain-slee.diameter by RestComm.

the class CxDxSessionFactory method getNewSession.

/* (non-Javadoc)
   * @see org.jdiameter.common.api.app.IAppSessionFactory#getNewSession(java.lang.String, java.lang.Class, org.jdiameter.api.ApplicationId, java.lang.Object[])
   */
public AppSession getNewSession(String sessionId, Class<? extends AppSession> appSessionClass, ApplicationId applicationId, Object[] args) {
    AppSession appSession = null;
    if (appSessionClass == ClientCxDxSession.class) {
        CxDxClientSessionImpl clientSession = null;
        clientSession = (CxDxClientSessionImpl) super.getNewSession(sessionId, appSessionClass, applicationId, args);
        appSession = clientSession;
    } else if (appSessionClass == ServerCxDxSession.class) {
        org.jdiameter.server.impl.app.cxdx.CxDxServerSessionImpl serverSession = null;
        serverSession = (CxDxServerSessionImpl) super.getNewSession(sessionId, appSessionClass, applicationId, args);
        appSession = serverSession;
    } else {
        throw new IllegalArgumentException("Wrong session class!![" + appSessionClass + "]. Supported[" + ServerCxDxSession.class + "," + ClientCxDxSession.class + "]");
    }
    return appSession;
}
Also used : CxDxClientSessionImpl(org.jdiameter.client.impl.app.cxdx.CxDxClientSessionImpl) ServerCxDxSession(org.jdiameter.api.cxdx.ServerCxDxSession) AppSession(org.jdiameter.api.app.AppSession) ClientCxDxSession(org.jdiameter.api.cxdx.ClientCxDxSession) CxDxServerSessionImpl(org.jdiameter.server.impl.app.cxdx.CxDxServerSessionImpl)

Example 7 with AppSession

use of org.jdiameter.api.app.AppSession 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)

Aggregations

AppSession (org.jdiameter.api.app.AppSession)7 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)4 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)4 AvpDataException (org.jdiameter.api.AvpDataException)4 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)4 InternalException (org.jdiameter.api.InternalException)4 OperationNotSupportedException (javax.naming.OperationNotSupportedException)3 StateChangeListener (org.jdiameter.api.app.StateChangeListener)3 ServerShSession (org.jdiameter.api.sh.ServerShSession)3 DiameterActivityHandle (org.mobicents.slee.resource.diameter.base.DiameterActivityHandle)3 IOException (java.io.IOException)1 ObjectName (javax.management.ObjectName)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 ApplicationId (org.jdiameter.api.ApplicationId)1 RawSession (org.jdiameter.api.RawSession)1 Session (org.jdiameter.api.Session)1 SessionFactory (org.jdiameter.api.SessionFactory)1 ClientAccSession (org.jdiameter.api.acc.ClientAccSession)1 ServerAccSession (org.jdiameter.api.acc.ServerAccSession)1 ClientAuthSession (org.jdiameter.api.auth.ClientAuthSession)1