当前位置: 首页>>代码示例>>Java>>正文


Java JNDIContextFactory类代码示例

本文整理汇总了Java中org.ofbiz.base.util.JNDIContextFactory的典型用法代码示例。如果您正苦于以下问题:Java JNDIContextFactory类的具体用法?Java JNDIContextFactory怎么用?Java JNDIContextFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JNDIContextFactory类属于org.ofbiz.base.util包,在下文中一共展示了JNDIContextFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransactionManager

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public TransactionManager getTransactionManager() {
    if (transactionManager == null) {
        synchronized (JNDITransactionFactory.class) {
            // try again inside the synch just in case someone when through while we were waiting
            if (transactionManager == null) {
                try {
                    String jndiName = EntityConfig.getInstance().getTransactionFactory().getTransactionManagerJndi().getJndiName();
                    String jndiServerName = EntityConfig.getInstance().getTransactionFactory().getTransactionManagerJndi().getJndiServerName();

                    if (UtilValidate.isNotEmpty(jndiName)) {
                        // if (Debug.verboseOn()) Debug.logVerbose("[JNDITransactionFactory.getTransactionManager] Trying JNDI name " + jndiName, module);

                        try {
                            InitialContext ic = JNDIContextFactory.getInitialContext(jndiServerName);

                            if (ic != null) {
                                transactionManager = (TransactionManager) ic.lookup(jndiName);
                            }
                        } catch (NamingException ne) {
                            Debug.logWarning(ne, "NamingException while finding TransactionManager named " + jndiName + " in JNDI.", module);
                            transactionManager = null;
                        }
                        if (transactionManager == null) {
                            Debug.logWarning("Failed to find TransactionManager named " + jndiName + " in JNDI.", module);
                        }
                    }
                } catch (GeneralException e) {
                    Debug.logError(e, module);
                    transactionManager = null;
                }
            }
        }
    }
    return transactionManager;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:36,代码来源:JNDITransactionFactory.java

示例2: getUserTransaction

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public UserTransaction getUserTransaction() {
    if (userTransaction == null) {
        synchronized (JNDITransactionFactory.class) {
            // try again inside the synch just in case someone when through while we were waiting
            if (userTransaction == null) {
                try {
                    String jndiName = EntityConfig.getInstance().getTransactionFactory().getUserTransactionJndi().getJndiName();
                    String jndiServerName = EntityConfig.getInstance().getTransactionFactory().getUserTransactionJndi().getJndiServerName();

                    if (UtilValidate.isNotEmpty(jndiName)) {

                        try {
                            InitialContext ic = JNDIContextFactory.getInitialContext(jndiServerName);

                            if (ic != null) {
                                userTransaction = (UserTransaction) ic.lookup(jndiName);
                            }
                        } catch (NamingException ne) {
                            Debug.logWarning(ne, "NamingException while finding UserTransaction named " + jndiName + " in JNDI.", module);
                            userTransaction = null;
                        }
                        if (userTransaction == null) {
                            Debug.logWarning("Failed to find UserTransaction named " + jndiName + " in JNDI.", module);
                        }
                    }
                } catch (GeneralException e) {
                    Debug.logError(e, module);
                    transactionManager = null;
                }
            }
        }
    }
    return userTransaction;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:35,代码来源:JNDITransactionFactory.java

示例3: load

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public synchronized void load() throws GenericServiceException {
    try {
        InitialContext jndi = JNDIContextFactory.getInitialContext(jndiServer);
        QueueConnectionFactory factory = (QueueConnectionFactory) jndi.lookup(jndiName);

        if (factory != null) {
            con = factory.createQueueConnection(userName, password);
            con.setExceptionListener(this);
            session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            queue = (Queue) jndi.lookup(queueName);
            if (queue != null) {
                QueueReceiver receiver = session.createReceiver(queue);

                receiver.setMessageListener(this);
                con.start();
                this.setConnected(true);
                Debug.logInfo("Listening to queue [" + queueName + "]...", module);
            } else {
                throw new GenericServiceException("Queue lookup failed.");
            }
        } else {
            throw new GenericServiceException("Factory (broker) lookup failed.");
        }
    } catch (NamingException ne) {
        throw new GenericServiceException("JNDI lookup problems; listener not running.", ne);
    } catch (JMSException je) {
        throw new GenericServiceException("JMS internal error; listener not running.", je);
    } catch (GeneralException ge) {
        throw new GenericServiceException("Problems with InitialContext; listener not running.", ge);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:32,代码来源:JmsQueueListener.java

示例4: load

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public synchronized void load() throws GenericServiceException {
    try {
        InitialContext jndi = JNDIContextFactory.getInitialContext(jndiServer);
        TopicConnectionFactory factory = (TopicConnectionFactory) jndi.lookup(jndiName);

        if (factory != null) {
            con = factory.createTopicConnection(userName, password);
            con.setExceptionListener(this);
            session = con.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topic = (Topic) jndi.lookup(topicName);
            if (topic != null) {
                TopicSubscriber subscriber = session.createSubscriber(topic);
                subscriber.setMessageListener(this);
                con.start();
                this.setConnected(true);
                if (Debug.infoOn()) Debug.logInfo("Listening to topic [" + topicName + "] on [" + jndiServer + "]...", module);
            } else {
                throw new GenericServiceException("Topic lookup failed.");
            }
        } else {
            throw new GenericServiceException("Factory (broker) lookup failed.");
        }
    } catch (NamingException ne) {
        throw new GenericServiceException("JNDI lookup problems; listener not running.", ne);
    } catch (JMSException je) {
        throw new GenericServiceException("JMS internal error; listener not running.", je);
    } catch (GeneralException ge) {
        throw new GenericServiceException("Problems with InitialContext; listener not running.", ge);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:31,代码来源:JmsTopicListener.java

示例5: getTransactionManager

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public TransactionManager getTransactionManager() {
    if (transactionManager == null) {
        synchronized (JNDIFactory.class) {
            // try again inside the synch just in case someone when through while we were waiting
            if (transactionManager == null) {
                try {
                    String jndiName = EntityConfigUtil.getTxFactoryTxMgrJndiName();
                    String jndiServerName = EntityConfigUtil.getTxFactoryTxMgrJndiServerName();

                    if (UtilValidate.isNotEmpty(jndiName)) {
                        // if (Debug.verboseOn()) Debug.logVerbose("[JNDIFactory.getTransactionManager] Trying JNDI name " + jndiName, module);

                        try {
                            InitialContext ic = JNDIContextFactory.getInitialContext(jndiServerName);

                            if (ic != null) {
                                transactionManager = (TransactionManager) ic.lookup(jndiName);
                            }
                        } catch (NamingException ne) {
                            Debug.logWarning(ne, "NamingException while finding TransactionManager named " + jndiName + " in JNDI.", module);
                            transactionManager = null;
                        }
                        if (transactionManager == null) {
                            Debug.logWarning("[JNDIFactory.getTransactionManager] Failed to find TransactionManager named " + jndiName + " in JNDI.", module);
                        }
                    }
                } catch (GeneralException e) {
                    Debug.logError(e, module);
                    transactionManager = null;
                }
            }
        }
    }
    return transactionManager;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:36,代码来源:JNDIFactory.java

示例6: getUserTransaction

import org.ofbiz.base.util.JNDIContextFactory; //导入依赖的package包/类
public UserTransaction getUserTransaction() {
    if (userTransaction == null) {
        synchronized (JNDIFactory.class) {
            // try again inside the synch just in case someone when through while we were waiting
            if (userTransaction == null) {
                try {
                    String jndiName = EntityConfigUtil.getTxFactoryUserTxJndiName();
                    String jndiServerName = EntityConfigUtil.getTxFactoryUserTxJndiServerName();

                    if (UtilValidate.isNotEmpty(jndiName)) {
                        // if (Debug.verboseOn()) Debug.logVerbose("[JNDIFactory.getTransactionManager] Trying JNDI name " + jndiName, module);

                        try {
                            InitialContext ic = JNDIContextFactory.getInitialContext(jndiServerName);

                            if (ic != null) {
                                userTransaction = (UserTransaction) ic.lookup(jndiName);
                            }
                        } catch (NamingException ne) {
                            Debug.logWarning(ne, "NamingException while finding UserTransaction named " + jndiName + " in JNDI.", module);
                            userTransaction = null;
                        }
                        if (userTransaction == null) {
                            Debug.logWarning("[JNDIFactory.getUserTransaction] Failed to find UserTransaction named " + jndiName + " in JNDI.", module);
                        }
                    }
                } catch (GeneralException e) {
                    Debug.logError(e, module);
                    transactionManager = null;
                }
            }
        }
    }
    return userTransaction;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:36,代码来源:JNDIFactory.java


注:本文中的org.ofbiz.base.util.JNDIContextFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。