热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javax.naming.spi.NamingManager类的使用及代码示例

本文整理了Java中javax.naming.spi.NamingManager类的一些代码示例,展示了NamingManager类的具体用法

本文整理了Java中javax.naming.spi.NamingManager类的一些代码示例,展示了NamingManager类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NamingManager类的具体详情如下:
包路径:javax.naming.spi.NamingManager
类名称:NamingManager

NamingManager介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

if (pos > 0) {
String scheme = name.substring(0, pos);
Context ctx = NamingManager.getURLContext(scheme, environment);
if (ctx == null) {
throw new NamingException("scheme " + scheme + " not recognized");
return ctx.lookup(name);
} else {
Object obj = bindings.get(first);
if (obj == null) {
throw new NameNotFoundException(name);
} else if (obj instanceof Context && path.size() > 1) {
Context subCOntext= (Context) obj;
obj = subContext.lookup(path.getSuffix(1));
result = NamingManager.getObjectInstance(result, null, null, this.environment);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
throw (NamingException) new NamingException("could not look up : " + name).initCause(e);

代码示例来源:origin: wildfly/wildfly

try {
obj = NamingManager.getStateToBind(obj, name, this, _env);
} catch (BAD_PARAM e) {
NamingException ne = new NotContextException(name.toString());
ne.setRootCause(e);
throw ne;
} catch (Exception e) {

代码示例来源:origin: spring-projects/spring-framework

/**
* Register the context builder by registering it with the JNDI NamingManager.
* Note that once this has been done, {@code new InitialContext()} will always
* return a context from this factory. Use the {@code emptyActivatedContextBuilder()}
* static method to get an empty context (for example, in test methods).
* @throws IllegalStateException if there's already a naming context builder
* registered with the JNDI NamingManager
*/
public void activate() throws IllegalStateException, NamingException {
logger.info("Activating simple JNDI environment");
synchronized (initializationLock) {
if (!initialized) {
Assert.state(!NamingManager.hasInitialContextFactoryBuilder(),
"Cannot activate SimpleNamingContextBuilder: there is already a JNDI provider registered. " +
"Note that JNDI is a JVM-wide service, shared at the JVM system class loader level, " +
"with no reset option. As a consequence, a JNDI provider must only be registered once per JVM.");
NamingManager.setInitialContextFactoryBuilder(this);
initialized = true;
}
}
activated = this;
}

代码示例来源:origin: org.mortbay.jetty/jetty-jndi

throw new NamingException ("This context is immutable");
throw new NamingException ("Name is null");
if (cname.size() == 0)
throw new NamingException ("Name is empty");
if (cname.size() == 1)
Object objToBind = NamingManager.getStateToBind(obj, name, this, null);
if (objToBind instanceof Referenceable)
if(Log.isDebugEnabled())Log.debug("Checking for existing binding for name="+cname+" for first element of name="+cname.get(0));
String firstCompOnent= cname.get(0);
Binding binding = getBinding (name.get(0));
if (binding == null)
throw new NameNotFoundException (name.get(0)+ " is not bound");
ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), this, _env);
((Context)ctx).rebind (cname.getSuffix(1), obj);
throw new NotContextException ("Object bound at "+firstComponent +" is not a Context");

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

if (cname.size() == 0)
String firstCompOnent= cname.get(0);
Object ctx = null;
throw new NameNotFoundException ();
if(__log.isDebugEnabled())__log.debug("Dereferencing Reference for "+name.get(0));
try
ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env);
throw new NamingException (e.getMessage());
throw new NotContextException();
return ((Context)ctx).list (cname.getSuffix(1));

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

if (cname.size() == 0)
String firstCompOnent= cname.get(0);
Object ctx = null;
throw new NameNotFoundException ();
ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), this, _env);
throw new NamingException (e.getMessage());
throw new NotContextException();
return ((Context)ctx).listBindings (cname.getSuffix(1));

代码示例来源:origin: wildfly/wildfly

if (_nc == null)
throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
if (name.size() == 0)
return this; // %%% should clone() so that env can be changed
NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name);
return NamingManager.getObjectInstance(answer, name, this, _env);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory();
ne.setRootCause(e);
throw ne;
return cctx.lookup(cpe.getRemainingName());

代码示例来源:origin: com.ironoreserver/com.ironoreserver.core

@Override
public Object lookup(Name name) throws NamingException {
if (name.isEmpty()) {
return this.clone();
String atomicName = normalizedName.get(0);
Object atomicNameBinding = bindings.get(atomicName);
if (normalizedName.size() == 1) {
if (atomicNameBinding == null) {
throw new NameNotFoundException("Name ["+atomicName+"] from ["+normalizedName+"] not found in this binding");
return NamingManager.getObjectInstance(
atomicNameBinding,
new CompositeName().add(atomicName),
env);
} catch (Exception e) {
NamingException _e = new NamingException("NamingManager.getObjectInstance(...) failed");
_e.setRootCause(e);
throw _e;
return ((Context)atomicNameBinding).lookup(normalizedName.getSuffix(1));
throw new NotContextException(atomicName+" from ["+name+"] is not a context, cannot perform further lookup");

代码示例来源:origin: enioka/jqm

public static void main(String[] args)
{
File o;
try
{
o = (File) NamingManager.getInitialContext(null).lookup("fs/test");
}
catch (NamingException e)
{
throw new RuntimeException("could not get the test directory", e);
}
System.out.println(o.getAbsolutePath());
}
}

代码示例来源:origin: org.jvnet.hudson.winstone/winstone

this.parent.bind(name, value, allowOverwrites);
} else if ((!allowOverwrites) && this.bindings.get(name.get(0)) != null)
throw new NamingException(ContainerJNDIManager.JNDI_RESOURCES.getString(
"WinstoneContext.AlreadyExists", name.toString()));
else {
value = NamingManager.getStateToBind(value, new CompositeName()
.add(bindName.get(0)), this, this.environment);
synchronized (this.contextLock) {

代码示例来源:origin: uk.org.retep.microkernel/jndi

value = NamingManager.getObjectInstance( value, name, this,
env );
throw new NamingException( ex.getMessage() );
if( lookup && name.size() > 1 )
return MemoryContext.class.cast( value ).lookupImpl( name.getSuffix( 1 ),
resolveLink );
return Context.class.cast( value ).lookup( name.getSuffix( 1 ) );
throw new NotContextException( simple + " is not a subcontext" );

代码示例来源:origin: org.jboss.as/jboss-as-naming

if (parsedName.namespace() == null) {
if (!parsedName.remaining().isEmpty()) {
final String firstPart = parsedName.remaining().get(0);
int index = firstPart.indexOf(':');
if (index != -1) {
if (factory != null) {
try {
return ((Context) factory.getObjectInstance(null, name, this, getEnvironment())).lookup(name);
}catch(NamingException e) {
throw e;
} catch (Exception e) {
NamingException n = new NamingException(e.getMessage());
n.initCause(e);
throw n;
Context ctx = NamingManager.getURLContext(scheme, getEnvironment());
if(ctx!=null){
return ctx.lookup(name);
return super.lookup(parsedName.remaining(),dereference);
else
return namespaceContext.lookup(parsedName.remaining());

代码示例来源:origin: org.apache.qpid/qpid-jca

/**
* Lookup an object in the default initial context
* @param context The context to use
* @param name the name to lookup
* @param clazz the expected type
* @return the object
* @throws Exception for any error
*/
public static T lookup(final Context context, final String name, final Class clazz) throws Exception
{
Object object = context.lookup(name);
if (object instanceof Reference)
{
return (T)NamingManager.getObjectInstance(object, null, null, null);
}
return clazz.cast(object);
}

代码示例来源:origin: org.ow2.carol/carol

/**
* Creates an Initial Context for beginning name resolution. Special
* requirements of this context are supplied using environment.
* @param env The possibly null environment specifying information
* to be used in the creation of the initial context.
* @return A non-null initial context object that implements the Context
* interface.
* @exception NamingException If cannot create an initial context.
*/
public Context getInitialContext(Hashtable env) throws NamingException {
String provider = (String) env.get(Context.PROVIDER_URL);
String protocol = provider.substring(0, provider.indexOf(':'));
Context ctx = NamingManager.getURLContext(protocol, env);
return (Context) ctx.lookup(provider);
}
}

代码示例来源:origin: org.objectweb.joram/jndi-shared

public final static Object resolveObject(Object obj) throws NamingException {
if (! (obj instanceof Reference))
return obj;
try {
return javax.naming.spi.NamingManager.getObjectInstance(
obj, null, null, null);
} catch (Exception e) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "", e);
NamingException ne = new NamingException(e.getMessage());
ne.setRootCause(e);
throw ne;
}
}
}

代码示例来源:origin: com.ironoreserver/com.ironoreserver.core

@Override
public void rebind(Name name, Object obj) throws NamingException {
if (name.isEmpty()) {
throw new InvalidNameException("Name ["+name+"] is empty ");
}

Name normalizedName = normalizeName(name);
String atomicName = normalizedName.get(0); // first component
Object atomicNameBinding = bindings.get(atomicName);

if (normalizedName.size() == 1) {
if (obj instanceof AbstractHierarchicalContext) {
((AbstractHierarchicalContext)obj).parent = this;
}
bindings.put(atomicName,
NamingManager.getStateToBind(obj, new CompositeName().add(atomicName), this, env));
}
else {
if (atomicNameBinding instanceof Context) {
((Context)atomicNameBinding).rebind(normalizedName.getSuffix(1), obj);
}
else {
throw new NotContextException(format("%s from [%s] is not a context, cannot perform further binding", atomicName, name));
}
}
}

代码示例来源:origin: com.ironoreserver/com.ironoreserver.core

@Override
public void bind(Name name, Object obj) throws NamingException {
if (name.isEmpty()) {
throw new InvalidNameException(format("Name [%s] is empty ", name));
}

Name normalizedName = normalizeName(name);
String atomicName = normalizedName.get(0); // first component
Object atomicNameBinding = bindings.get(atomicName);

if (normalizedName.size() == 1) {
if (atomicNameBinding != null) {
throw new NameAlreadyBoundException(format("Name [%s] in [%s] is already binded to [%s]", atomicName, normalizedName, atomicNameBinding));
}
bindings.put(atomicName,
NamingManager.getStateToBind(obj, new CompositeName().add(atomicName), this, env));
}
else {
if (atomicNameBinding instanceof Context) {
((Context)atomicNameBinding).bind(normalizedName.getSuffix(1), obj);
}
else {
throw new NotContextException(format("%s from [%s] is not a context, cannot perform further binding", atomicName, name));
}
}
}

代码示例来源:origin: org.apache.xbean/xbean-naming

public static Object resolve(Object value, String stringName, Name parsedName, Context nameCtx) throws NamingException {
if (!(value instanceof Reference)) {
return value;
}
Reference reference = (Reference) value;
// for SimpleReference we can just call the getContext method
if (reference instanceof SimpleReference) {
try {
return ((SimpleReference) reference).getContent();
} catch (NamingException e) {
throw e;
} catch (Exception e) {
throw (NamingException) new NamingException("Could not look up : " + stringName == null? parsedName.toString(): stringName).initCause(e);
}
}
// for normal References we have to do it the slow way
try {
if (parsedName == null) {
parsedName = NAME_PARSER.parse(stringName);
}
return NamingManager.getObjectInstance(reference, parsedName, nameCtx, nameCtx.getEnvironment());
} catch (NamingException e) {
throw e;
} catch (Exception e) {
throw (NamingException) new NamingException("Could not look up : " + stringName == null? parsedName.toString(): stringName).initCause(e);
}
}

代码示例来源:origin: carol/carol

public Object lookup(String name) throws NamingException {
if (TraceCarol.isDebugJndiCarol())
TraceCarol.debugJndiCarol("lookup(" + name + ")");
if (name.equals("")) {
// Asking to look up this context itself. Create and return
// a new instance with its own independent environment.
return (new FlatCtx(myEnv));
}
try {
Object obj = reg.lookup(name);
if (obj instanceof RemoteReference) {
return NamingManager.getObjectInstance(
((RemoteReference) obj).getReference(),
null,
this,
this.myEnv);
}
if (TraceCarol.isDebugJndiCarol())
TraceCarol.debugJndiCarol("lookup(" + name + ") returned");
return obj;
} catch (java.rmi.NotBoundException e) {
throw new NameNotFoundException(e.toString());
} catch (Exception e) {
throw new NamingException(e.toString());
}
}

代码示例来源:origin: wildfly/wildfly

NamingException ne = new NameNotFoundException();
ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
ne.setRootCause(e);
throw ne;
java.lang.Object resolvedObj2;
try {
resolvedObj2 = NamingManager.getObjectInstance(resolvedObj,
cname, ctx, ctx._env);
} catch (NamingException ge) {
} catch (Exception ge) {
NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory();
ne.setRootCause(ge);
throw ne;
} else {
cname.add("");
cpe.setAltName(cname);

推荐阅读
author-avatar
wujianhong61391
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有