Package org.smpp

Examples of org.smpp.Session$UnbindServerPDUEventListener


     * @throws IOException if there was a problem running the test
     */
    public void testValidateObject() throws MessageException, IOException {
        sessionFactory = new PoolableSessionFactory(
                ADDRESS, PORT, USERNAME, PASSWORD, SYNC_BINDTYPE);
        Session session = (Session) sessionFactory.makeObject();
        assertTrue(session.isOpened());
        assertTrue(session.isBound());
        assertTrue(sessionFactory.validateObject(session));

        sessionFactory.destroyObject(session);
        assertFalse(sessionFactory.validateObject(session));
    }
View Full Code Here


     * @throws IOException if there was a problem running the test
     */
    public void testValidateObjectFailsWhenAsynchronous()
            throws MessageException, IOException {
        // Create an object to test with.
        Session session = (Session) sessionFactory.makeObject();
        assertTrue(session.isOpened());
        assertTrue(session.isBound());
        // Validation checks that the object is a Session, is opened and bound
        // and responds to EnquireLink PDUs. Asynchronous comms means the
        // validation method gets no response to the EnquireLink PDU and so it
        // always fails.
        assertFalse(sessionFactory.validateObject(session));
View Full Code Here

     */
    public void testBindAndUnbindHandleSynchronousAndAsynchronous()
            throws MessageException, WrongSessionStateException,
            TimeoutException, IOException, PDUException {
        // Verify that binding using an asynchronous factory is fine.
        Session session = new Session(new TCPIPConnection(ADDRESS, PORT));
        sessionFactory.bind(session);
        sessionFactory.unbind(session);

        // Verify that binding using a synchronous factory is fine.
        sessionFactory = new PoolableSessionFactory(
                ADDRESS, PORT, USERNAME, PASSWORD, SYNC_BINDTYPE);
        session = new Session(new TCPIPConnection(ADDRESS, PORT));
        sessionFactory.bind(session);
        sessionFactory.unbind(session);
    }
View Full Code Here

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Attempting to borrow a session from the pool");
        }

        Session session = null;
        while (session == null) {
            if (available.isEmpty()) {
                if (hasRoom() || whenExhaustedAction == WHEN_EXHAUSTED_GROW) {
                    // There are no available sessions, but there is room to
                    // create a new one.
View Full Code Here

    public synchronized void addObject() throws Exception {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Attempting to add a session to the pool");
        }
        if (hasRoom()) {
            Session session = (Session) objectFactory.makeObject();
            available.add(session);
        } else {
            // can't create an object right now...
            throw new SessionException(EXCEPTION_LOCALIZER.format(
                    "session-pool-full"));
View Full Code Here

     * @return Session the next available session. May be null if none is available
     * @throws Exception if there was a problem getting the next available session
     */
    private Session getNextAvailableSession() throws Exception {

        Session session = null;
        Iterator iterator = available.iterator();

        // Try all of the available sessions to get a valid one
        ArrayList badObjects = new ArrayList();
        while (iterator.hasNext() && session == null) {
View Full Code Here

     * @throws Exception if there was a problem validating the session
     */
    private Session handleExhaustedPool()
            throws NoSuchElementException, InterruptedException, Exception {
        // There are no available sessions, and can't create any...
        Session session = null;
        if (whenExhaustedAction == WHEN_EXHAUSTED_FAIL) {
            throw new NoSuchElementException(
                    EXCEPTION_LOCALIZER.format("session-pool-exhausted"));
        } else if (whenExhaustedAction == WHEN_EXHAUSTED_BLOCK) {
            // block for a bit and try again...
View Full Code Here

    // Javadoc inherited.
    public Object makeObject() throws MessageException {
        Connection connection = new TCPIPConnection(address, port);
        connection.setReceiveTimeout(20 * 1000);
        Session session = new Session(connection);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Created a new org.smpp.Session : "+ session);
        }
        bind(session);
        return session;
View Full Code Here

    }

    // Javadoc inherited.
    public void destroyObject(Object object) throws MessageException {
        try {
            Session session = (Session) object;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Destroying org.smpp.Session : " + session);
            }
            // Unbind the session.
            unbind(session);

            // Close the unbound session.
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Attempting to close Session.");
            }
            session.close();
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Successfully closed Session.");
            }

            // Close any associated connection.
            Connection c = session.getConnection();
            if (c != null) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Attempting to close the open connection.");
                }
                c.close();
View Full Code Here

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Validating session object : " + object);
        }

        if (object instanceof Session) {
            Session session = (Session) object;

            // Verify that the session is open, bound and responsive to
            // enquire link PDUs.
            if (session.isOpened() && session.isBound() &&
                    SessionValidator.sendEnquireLink(session)) {
                isValid = true;
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Session was successfully validated");
                }
View Full Code Here

TOP

Related Classes of org.smpp.Session$UnbindServerPDUEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.