Package javax.jms

Examples of javax.jms.JMSContext


    public JMSContextManager() {
        contexts = new HashMap<String, JMSContext>();
    }

    public JMSContext getContext(String id, JMSContextMetadata metadata, ConnectionFactory connectionFactory) {
        JMSContext context = contexts.get(id);
        if (context == null) {
            int sessionMode = metadata.getSessionMode();
            String userName = metadata.getUserName();
            if (userName == null) {
                context = connectionFactory.createContext(sessionMode);
            } else {
                String password = metadata.getPassword();
                context = connectionFactory.createContext(userName, password, sessionMode);
            }
            logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.create",
                                   "Created new JMSContext instance associated with id {0}: {1}.",
                                   id, context.toString()));
            contexts.put(id, context);
        }
        return context;
    }
View Full Code Here


   // Close and remove the JMSContext instances
   @PreDestroy
   public void cleanup() {
       for (Entry<String, JMSContext> entry : contexts.entrySet()) {
           String id = entry.getKey();
           JMSContext context = entry.getValue();
           try {
               context.close();
               logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.close",
                                      "Closed JMSContext instance associated with id {0}: {1}.",
                                      id, context.toString()));
           } catch (Exception e) {
               logger.log(Level.SEVERE, localStrings.getLocalString("JMSContext.impl.close.failure",
                                        "Failed to close JMSContext instance associated with id {0}: {1}.",
                                        id, context.toString()), e);
           }
       }
       contexts.clear();
   }
View Full Code Here

        }
    }

    @Override
    public String toString() {
        JMSContext rContext = null;
        JMSContext tContext = null;
        try {
            boolean isInTransaction = isInTransaction();
            if (isInTransaction) {
                tContext = transactedManager.getContext(id);
                if (tContext == null)
View Full Code Here

        }
    }

    @Override
    public String toString() {
        JMSContext rContext = null;
        JMSContext tContext = null;
        try {
            boolean isInTransaction = isInTransaction();
            if (isInTransaction) {
                TransactedJMSContextManager manager = getTransactedManager();
                tContext = manager.getContext(id);
View Full Code Here

    }

    protected JMSContext createContext(String ipId, JMSContextMetadata metadata, ConnectionFactory connectionFactory) {
        int sessionMode = metadata.getSessionMode();
        String userName = metadata.getUserName();
        JMSContext context = null;
        if (userName == null) {
            context = connectionFactory.createContext(sessionMode);
        } else {
            String password = metadata.getPassword();
            context = connectionFactory.createContext(userName, password, sessionMode);
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.create",
                                   "Created new JMSContext instance associated with id {0}: {1}.",
                                   ipId, context.toString()));
        }
        return context;
    }
View Full Code Here

        return context;
    }

    public synchronized JMSContext getContext(String ipId, String id, JMSContextMetadata metadata, ConnectionFactory connectionFactory) {
        JMSContextEntry contextEntry = contexts.get(id);
        JMSContext context = null;
        if (contextEntry == null) {
            context = createContext(ipId, metadata, connectionFactory);
            ServiceLocator serviceLocator = Globals.get(ServiceLocator.class);
            InvocationManager invMgr = serviceLocator.getService(InvocationManager.class);
            contexts.put(id, new JMSContextEntry(ipId, context, invMgr.getCurrentInvocation()));
View Full Code Here

        return context;
    }

    public JMSContext getContext(String id) {
        JMSContextEntry entry = contexts.get(id);
        JMSContext context = null;
        if (entry != null)
            context = entry.getCtx();
        return context;
    }
View Full Code Here

        ComponentInvocation currentInv = invMgr.getCurrentInvocation();

        for (Entry<String, JMSContextEntry> entry : contexts.entrySet()) {
            JMSContextEntry contextEntry = entry.getValue();
            String ipId = contextEntry.getInjectionPointId();
            JMSContext context = contextEntry.getCtx();
            if (context != null) {
                ComponentInvocation inv = contextEntry.getComponentInvocation();
                if (inv != null && currentInv != inv) invMgr.preInvoke(inv);
                try {
                    context.close();
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.close",
                                               "Closed JMSContext instance associated with id {0}: {1}.",
                                               ipId, context.toString()));
                    }
                } catch (Exception e) {
                    logger.log(Level.SEVERE, localStrings.getLocalString("JMSContext.impl.close.failure",
                                             "Failed to close JMSContext instance associated with id {0}: {1}.",
                                             ipId, context.toString()), e);
                } finally {
                    if (inv != null && currentInv != inv) invMgr.postInvoke(inv);
                }
            }
        }
View Full Code Here

    }

    protected JMSContext createContext(String ipId, JMSContextMetadata metadata, ConnectionFactory connectionFactory) {
        int sessionMode = metadata.getSessionMode();
        String userName = metadata.getUserName();
        JMSContext context = null;
        if (userName == null) {
            context = connectionFactory.createContext(sessionMode);
        } else {
            String password = metadata.getPassword();
            context = connectionFactory.createContext(userName, password, sessionMode);
        }
        logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.create",
                               "Created new JMSContext instance associated with id {0}: {1}.",
                               ipId, context.toString()));
        return context;
    }
View Full Code Here

        return context;
    }

    public synchronized JMSContext getContext(String ipId, String id, JMSContextMetadata metadata, ConnectionFactory connectionFactory) {
        JMSContextEntry contextEntry = contexts.get(id);
        JMSContext context = null;
        if (contextEntry == null) {
            context = createContext(ipId, metadata, connectionFactory);
            contexts.put(id, new JMSContextEntry(ipId, context));
        } else {
            context = contextEntry.getCtx();
View Full Code Here

TOP

Related Classes of javax.jms.JMSContext

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.