• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ContextBindings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Bind current thread, both for CL purposes and for JNDI ENC support
 * during : startup, shutdown and realoading of the context.
 *
 * @return the previous context class loader
 */
private ClassLoader bindThread() {

    ClassLoader oldContextClassLoader =
        Thread.currentThread().getContextClassLoader();

    if (getResources() == null)
        return oldContextClassLoader;

    Thread.currentThread().setContextClassLoader
        (getLoader().getClassLoader());

    DirContextURLStreamHandler.bind(getResources());

    if (isUseNaming()) {
        try {
            ContextBindings.bindThread(this, this);
        } catch (NamingException e) {
            // Silent catch, as this is a normal case during the early
            // startup stages
        }
    }

    return oldContextClassLoader;

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:32,代码来源:StandardContext.java


示例2: bindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Bind current thread, both for CL purposes and for JNDI ENC support during
 * : startup, shutdown and realoading of the context.
 *
 * @return the previous context class loader
 */
protected ClassLoader bindThread() {

	ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();

	if (getResources() == null)
		return oldContextClassLoader;

	if (getLoader() != null && getLoader().getClassLoader() != null) {
		Thread.currentThread().setContextClassLoader(getLoader().getClassLoader());
	}

	DirContextURLStreamHandler.bindThread(getResources());

	if (isUseNaming()) {
		try {
			ContextBindings.bindThread(this, this);
		} catch (NamingException e) {
			// Silent catch, as this is a normal case during the early
			// startup stages
		}
	}

	return oldContextClassLoader;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:StandardContext.java


示例3: open

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Open the specified database connection.
 *
 * @return Connection to the database
 */
protected Connection open() {

    try {
        Context context = null;
        if (localDataSource) {
            context = ContextBindings.getClassLoader();
            context = (Context) context.lookup("comp/env");
        } else {
            context = getServer().getGlobalNamingContext();
        }
        DataSource dataSource = (DataSource)context.lookup(dataSourceName);
    return dataSource.getConnection();
    } catch (Exception e) {
        // Log the problem for posterity
        containerLog.error(sm.getString("dataSourceRealm.exception"), e);
    }  
    return null;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:DataSourceRealm.java


示例4: 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


示例5: contextEntered

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext) {
    // save off the old context if possible
    try {
        final Data data = new Data(getThreadName());
        newContext.set(Data.class, data);
    } catch (final NamingException ignored) {
        // no-op
    }

    // set the new context
    try {
        ContextBindings.bindThread(OPENEJB_CONTEXT, null);
    } catch (final NamingException e) {
        ContextBindings.unbindContext(OPENEJB_CONTEXT, null);
        throw new IllegalArgumentException("Unable to bind OpenEJB enc");
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:21,代码来源:TomcatThreadContextListener.java


示例6: bindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Bind current thread, both for CL purposes and for JNDI ENC support
 * during : startup, shutdown and realoading of the context.
 *
 * @return the previous context class loader
 */
protected ClassLoader bindThread() {

    ClassLoader oldContextClassLoader =
        Thread.currentThread().getContextClassLoader();

    if (getResources() == null)
        return oldContextClassLoader;

    if (getLoader() != null && getLoader().getClassLoader() != null) {
        Thread.currentThread().setContextClassLoader
            (getLoader().getClassLoader());
    }

    DirContextURLStreamHandler.bindThread(getResources());

    if (isUseNaming()) {
        try {
            ContextBindings.bindThread(this, this);
        } catch (NamingException e) {
            // Silent catch, as this is a normal case during the early
            // startup stages
        }
    }

    return oldContextClassLoader;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:34,代码来源:StandardContext.java


示例7: unbindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Unbind thread.
 */
protected void unbindThread(ClassLoader oldContextClassLoader) {

    if (isUseNaming()) {
        ContextBindings.unbindThread(this, this);
    }

    DirContextURLStreamHandler.unbindThread();

    Thread.currentThread().setContextClassLoader(oldContextClassLoader);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:14,代码来源:StandardContext.java


示例8: getObjectInstance

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Crete a new Context's instance.
 */
@SuppressWarnings("unchecked")
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                Hashtable<?,?> environment)
    throws NamingException {
    if ((ContextBindings.isThreadBound()) || 
        (ContextBindings.isClassLoaderBound())) {
        return new SelectorContext((Hashtable<String,Object>)environment);
    }
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:javaURLContextFactory.java


示例9: bindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Bind current thread, both for CL purposes and for JNDI ENC support
 * during : startup, shutdown and realoading of the context.
 *
 * @return the previous context class loader
 */
private ClassLoader bindThread() {

    ClassLoader oldContextClassLoader =
        Thread.currentThread().getContextClassLoader();

    if (getResources() == null)
        return oldContextClassLoader;

    if (getLoader().getClassLoader() != null) {
        Thread.currentThread().setContextClassLoader
            (getLoader().getClassLoader());
    }

    DirContextURLStreamHandler.bind(getResources());

    if (isUseNaming()) {
        try {
            ContextBindings.bindThread(this, this);
        } catch (NamingException e) {
            // Silent catch, as this is a normal case during the early
            // startup stages
        }
    }

    return oldContextClassLoader;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:StandardContext.java


示例10: getObjectInstance

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Crete a new Context's instance.
 */
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                Hashtable environment)
    throws NamingException {
    if ((ContextBindings.isThreadBound()) || 
        (ContextBindings.isClassLoaderBound())) {
        return new SelectorContext(environment);
    } else {
        return null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:javaURLContextFactory.java


示例11: unbindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Unbind thread.
 */
protected void unbindThread(ClassLoader oldContextClassLoader) {

	if (isUseNaming()) {
		ContextBindings.unbindThread(this, this);
	}

	DirContextURLStreamHandler.unbindThread();

	Thread.currentThread().setContextClassLoader(oldContextClassLoader);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:14,代码来源:StandardContext.java


示例12: getObjectInstance

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Crete a new Context's instance.
 */
@SuppressWarnings("unchecked")
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
		throws NamingException {
	if ((ContextBindings.isThreadBound()) || (ContextBindings.isClassLoaderBound())) {
		return new SelectorContext((Hashtable<String, Object>) environment);
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:javaURLContextFactory.java


示例13: 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


示例14: 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


示例15: 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


示例16: bindThread

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Bind current thread, both for CL purposes and for JNDI ENC support
 * during : startup, shutdown and realoading of the context.
 *
 * @return the previous context class loader
 */
protected ClassLoader bindThread() {

    ClassLoader oldContextClassLoader =
        Thread.currentThread().getContextClassLoader();

    if (getResources() == null)
        return oldContextClassLoader;

    if (getLoader().getClassLoader() != null) {
        Thread.currentThread().setContextClassLoader
            (getLoader().getClassLoader());
    }

    DirContextURLStreamHandler.bindThread(getResources());

    if (isUseNaming()) {
        try {
            ContextBindings.bindThread(this, this);
        } catch (NamingException e) {
            // Silent catch, as this is a normal case during the early
            // startup stages
        }
    }

    return oldContextClassLoader;

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:34,代码来源:StandardContext.java


示例17: TomcatThreadContextListener

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Creates a new instance.
 */
public TomcatThreadContextListener() {
    ContextBindings.bindContext(OPENEJB_CONTEXT, new OpenEJBContext());
    try {
        // someone decided to make the getThreadName package protected so we have to use reflection
        method = ContextBindings.class.getDeclaredMethod("getThreadName");
        method.setAccessible(true);

        final Field threadNameBindingsField = ContextBindings.class.getDeclaredField("threadObjectBindings");
        threadNameBindingsField.setAccessible(true);
        threadNameBindings = (Hashtable<Thread, Object>) threadNameBindingsField.get(null);
    } catch (final Exception e) {
        logger.error("Expected ContextBinding to have the method getThreadName()");
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:18,代码来源:TomcatThreadContextListener.java


示例18: contextExited

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void contextExited(final ThreadContext exitedContext, final ThreadContext reenteredContext) {
    // unbind the new context
    ContextBindings.unbindThread(OPENEJB_CONTEXT, null);

    // attempt to restore the old context
    final Data data = exitedContext.get(Data.class);
    if (data != null && data.oldContextName != null) {
        try {
            ContextBindings.bindThread(data.oldContextName, null);
        } catch (final NamingException e) {
            logger.error("Exception in method contextExited", e);
        }
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:18,代码来源:TomcatThreadContextListener.java


示例19: open

import org.apache.naming.ContextBindings; //导入依赖的package包/类
@Override
protected Connection open() {
    try { // parent behavior
        final Context context;
        if (fullName != null) {
            return DataSource.class.cast(openejbContext().lookup(fullName)).getConnection();
        }

        // parent behavior
        if (localDataSource) {
            context = Context.class.cast(ContextBindings.getClassLoader().lookup("comp/env"));
        } else {
            context = getServer().getGlobalNamingContext();
        }
        return DataSource.class.cast(context.lookup(dataSourceName)).getConnection();
    } catch (final Exception e) {
        try { // try globally
            return getConnection(dataSourceName);
        } catch (final Exception e2) {
            try { // try globally but with custom subspace
                return getConnection(OPENEJB_RESOURCE_PREFIX + dataSourceName);
            } catch (final Exception e3) {
                // try to guess the real name
                final Collection<String> ids = new ConfigurationFactory(true).getResourceIds(DataSource.class.getName(), new Properties());
                final String id = AutoConfig.findResourceId(ids, dataSourceName);

                if (id != null) {
                    try {
                        return getConnection(OPENEJB_RESOURCE_PREFIX + id);
                    } catch (final Exception e4) {
                        containerLog.error(sm.getString("dataSourceRealm.exception"), e);
                    }
                } else {
                    containerLog.error(sm.getString("dataSourceRealm.exception"), e);
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:tomee,代码行数:41,代码来源:TomEEDataSourceRealm.java


示例20: getThreadContext

import org.apache.naming.ContextBindings; //导入依赖的package包/类
/**
 * Gets current context deployment context.
 *
 * @return context of deployment
 * @throws NamingException for exception
 */
private Context getThreadContext() throws NamingException {
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    if (skipEjbContext(threadContext)) {
        return ContextBindings.getClassLoader();
    }
    final Context context = threadContext.getBeanContext().getJndiEnc();
    return context;
}
 
开发者ID:apache,项目名称:tomee,代码行数:15,代码来源:OpenEJBContext.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Range类代码示例发布时间:2022-05-21
下一篇:
Java BehaviorSkinBase类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap