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


Java ContextBindings.bindClassLoader方法代码示例

本文整理汇总了Java中org.apache.naming.ContextBindings.bindClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java ContextBindings.bindClassLoader方法的具体用法?Java ContextBindings.bindClassLoader怎么用?Java ContextBindings.bindClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.naming.ContextBindings的用法示例。


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

示例1: lookupDataSource

import org.apache.naming.ContextBindings; //导入方法依赖的package包/类
public synchronized DataSource lookupDataSource(final Context context, String resourceName) throws NamingException {
    if (context != null) {
        ContextBindings.bindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
    }
    try {
        String jndiName = resolveJndiName(resourceName, (context == null));
        Object o = new InitialContext().lookup(jndiName);

        if (o instanceof DataSource) {
            return (DataSource) o;
        } else {
            return null;
        }
    } finally {
        if (context != null) {
            ContextBindings.unbindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
        }
    }
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:20,代码来源:ResourceResolverBean.java

示例2: changeContextBinding

import org.apache.naming.ContextBindings; //导入方法依赖的package包/类
/**
 * Change context binding.
 *
 * @param context the context
 * @param bind the bind
 * @throws NamingException the naming exception
 */
private void changeContextBinding(Context context, boolean bind) throws NamingException {
  Object token = getNamingToken(context);
  ClassLoader loader = Thread.currentThread().getContextClassLoader();
  if (bind) {
    ContextBindings.bindClassLoader(context, token, loader);
  } else {
    ContextBindings.unbindClassLoader(context, token, loader);
  }
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:17,代码来源:AbstractTomcatContainer.java

示例3: getApplicationResources

import org.apache.naming.ContextBindings; //导入方法依赖的package包/类
public synchronized List getApplicationResources(Context context, ContainerWrapperBean containerWrapper) throws NamingException {

        List resourceList = new ArrayList();

        boolean contextAvailable = containerWrapper.getTomcatContainer().getAvailable(context);
        if (contextAvailable) {

            logger.info("Reading CONTEXT " + context.getName());

            boolean contextBound = false;

            try {
                ContextBindings.bindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
                contextBound = true;
            } catch (NamingException e) {
                logger.error("Cannot bind to context. useNaming=false ?");
                logger.debug("  Stack trace:", e);
            }

            try {
            	containerWrapper.getTomcatContainer().addContextResource(context, resourceList, contextBound);

            	containerWrapper.getTomcatContainer().addContextResourceLink(context, resourceList, contextBound);
            	for (int i = 0 ; i < resourceList.size() ; i++) {
            		lookupResource((ApplicationResource) resourceList.get(i), contextBound, false);
            	}
            	
            } finally {
                if (contextBound) {
                    ContextBindings.unbindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
                }
            }
        }

        return resourceList;
    }
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:37,代码来源:ResourceResolverBean.java

示例4: resetResource

import org.apache.naming.ContextBindings; //导入方法依赖的package包/类
public synchronized boolean resetResource(final Context context, String resourceName) throws NamingException {
    if (context != null) {
        ContextBindings.bindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
    }
    try {
        String jndiName = resolveJndiName(resourceName, (context == null));
        Object o = new InitialContext().lookup(jndiName);
        try {
            for (Iterator it = datasourceMappers.iterator(); it.hasNext();) {
                DatasourceAccessor accessor = (DatasourceAccessor) it.next();
                if (accessor.reset(o)) {
                    return true;
                }
            }
            return false;
        } catch (Throwable e) {
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
            return false;
        }
    } finally {
        if (context != null) {
            ContextBindings.unbindClassLoader(context, null, Thread.currentThread().getContextClassLoader());
        }
    }
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:31,代码来源:ResourceResolverBean.java


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