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


Java ContextBindings类代码示例

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


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


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