本文整理匯總了Java中javax.naming.NameAlreadyBoundException類的典型用法代碼示例。如果您正苦於以下問題:Java NameAlreadyBoundException類的具體用法?Java NameAlreadyBoundException怎麽用?Java NameAlreadyBoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NameAlreadyBoundException類屬於javax.naming包,在下文中一共展示了NameAlreadyBoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createQueue
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public void createQueue(String name) throws Exception {
if ( usingJNDI ) {
// Assumes use of ME01 SupportPac for WMQInitialContextFactory
Queue queue = configureMQQueue( new MQQueue(name) );
try {
getInitialContext().bind( name, queue );
} catch ( NameAlreadyBoundException e ) {
// No op - already exists
}
} else {
// "new" PCF style.
PCFMessageAgent agent = new PCFMessageAgent( Config.parms.getString("jh"), Config.parms.getInt("jp"), "CLIENT" );
PCFMessage message = new PCFMessage( CMQCFC.MQCMD_CREATE_Q );
message.addParameter( CMQC.MQCA_Q_NAME, name);
agent.send( message );
}
}
示例2: bind
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
@Override
public void bind(Name name, Object obj) throws NamingException {
if (name.isEmpty()) {
throw new InvalidNameException("Cannot bind empty name");
}
Name nm = getMyComponents(name);
String atom = nm.get(0);
Object inter = iBindings.get(atom);
if (nm.size() == 1) {
if (inter != null)
throw new NameAlreadyBoundException("Use rebind to override");
obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);
iBindings.put(atom, obj);
} else {
if (!(inter instanceof Context))
throw new NotContextException(atom + " does not name a context");
((Context) inter).bind(nm.getSuffix(1), obj);
}
}
示例3: createSubcontext
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
@Override
public Context createSubcontext(Name name) throws NamingException {
if (name.isEmpty())
throw new InvalidNameException("Cannot bind empty name");
Name nm = getMyComponents(name);
String atom = nm.get(0);
Object inter = iBindings.get(atom);
if (nm.size() == 1) {
if (inter != null)
throw new NameAlreadyBoundException("Use rebind to override");
Context child = createCtx(this, atom, iEnv);
iBindings.put(atom, child);
return child;
} else {
if (!(inter instanceof Context))
throw new NotContextException(atom + " does not name a context");
return ((Context) inter).createSubcontext(nm.getSuffix(1));
}
}
示例4: lookupTopic
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public DestinationWrapper<Topic> lookupTopic( String topic, Session session ) throws JMSException, NamingException {
if ( usingJNDI || session==null ) {
if ( autoCreateTopics ) {
Topic t = configureMQTopic( (MQTopic)session.createTopic( topic ) );
try {
getInitialContext().bind( topic, t );
Log.logger.fine( "Auto-created JNDI entry for "+topic );
} catch ( NameAlreadyBoundException e ) {
// No op - already exists
}
} // end if
return lookupTopicFromJNDI( topic );
} else {
return new DestinationWrapper<Topic>(topic,
configureMQTopic((MQTopic) session.createTopic(topic)));
}
}
示例5: rename
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
/**
* Binds a new name to the object bound to an old name, and unbinds the old name. Both names are relative to this context. Any attributes associated with the old name
* become associated with the new name. Intermediate contexts of the old name are not changed.
*
* @param oldName
* the name of the existing binding; may not be empty
* @param newName
* the name of the new binding; may not be empty
* @exception NameAlreadyBoundException
* if newName is already bound
* @exception NamingException
* if a naming exception is encountered
*/
@Override
public void rename(String oldName, String newName) throws NamingException {
VFSItem oldFile = resolveFile(oldName);
if (oldFile == null)
throw new NamingException(smgr.getString("resources.notFound", oldName));
VFSItem newFile = resolveFile(newName);
if (newFile != null)
throw new NameAlreadyBoundException();
VFSStatus status = oldFile.rename(newName);
if (status == VFSConstants.NO)
throw new NameAlreadyBoundException();
}
示例6: createSubcontext
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
/**
* Creates and binds a new context, along with associated attributes. This method creates a new subcontext with the given name, binds it in the target context (that
* named by all but terminal atomic component of the name), and associates the supplied attributes with the newly created object. All intermediate and target contexts
* must already exist. If attrs is null, this method is equivalent to Context.createSubcontext().
*
* @param name
* the name of the context to create; may not be empty
* @param attrs
* the attributes to associate with the newly created context
* @return the newly created context
* @exception NameAlreadyBoundException
* if the name is already bound
* @exception InvalidAttributesException
* if attrs does not contain all the mandatory attributes required for creation
* @exception NamingException
* if a naming exception is encountered
*/
@Override
public DirContext createSubcontext(String name, Attributes attrs) throws NamingException {
VFSItem file = resolveFile(name);
if (file != null)
throw new NameAlreadyBoundException(smgr.getString("resources.alreadyBound", name));
int lastSlash = name.lastIndexOf('/');
if (lastSlash == -1)
throw new NamingException();
String parent = name.substring(0, lastSlash);
VFSItem folder = resolveFile(parent);
if (folder == null || (!(folder instanceof VFSContainer)))
throw new NamingException(smgr.getString("resources.bindFailed", name));
String newName = name.substring(lastSlash + 1);
VFSItem childContainer = ((VFSContainer) folder).createChildContainer(newName);
if (childContainer == null)
throw new NamingException(smgr.getString("resources.bindFailed", name));
return (DirContext) lookup(name);
}
示例7: rename
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
/**
* Binds a new name to the object bound to an old name, and unbinds the old name. Both names are relative to this
* context. Any attributes associated with the old name become associated with the new name. Intermediate contexts
* of the old name are not changed.
*
* @param oldname The name of the existing binding; may not be empty.
* @param newname The new name of the binding; may not be empty.
*
* @throws NamingException If newname is bound, oldname cannot be found or one of the names is illegal.
*/
public void rename(String oldname, String newname) throws NamingException
{
if ("".equals(oldname) || "".equals(newname))
{
throw new InvalidNameException("Cannot rename empty name");
}
// Check if new name exists
if (bindings.get(newname) != null)
{
throw new NameAlreadyBoundException(newname + " is already bound");
}
// Check if old name is bound
Object oldBinding = bindings.remove(oldname);
if (oldBinding == null)
{
throw new NameNotFoundException(oldname + " not bound");
}
bindings.put(newname, oldBinding);
}
示例8: bind
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
@Override
public void bind(Name name, Object obj) throws NamingException
{
if (name.isEmpty())
throw new InvalidNameException("Cannot bind empty name");
// Extract components that belong to this namespace
String nm = name.toString();
// Find object in internal hash table
if (bindings.get(nm) != null)
{
throw new NameAlreadyBoundException("Use rebind to override");
}
// Add object to internal hash table
bindings.put(nm, obj);
}
示例9: rename
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
@Override
public void rename(Name oldname, Name newname) throws NamingException
{
if (oldname.isEmpty() || newname.isEmpty())
throw new InvalidNameException("Cannot rename empty name");
// Extract components that belong to this namespace
String oldnm = oldname.toString();
String newnm = newname.toString();
// Check if new name exists
if (bindings.get(newnm) != null)
throw new NameAlreadyBoundException(newname.toString() + " is already bound");
// Check if old name is bound
Object oldBinding = bindings.remove(oldnm);
if (oldBinding == null)
throw new NameNotFoundException(oldname.toString() + " not bound");
bindings.put(newnm, oldBinding);
}
示例10: bind
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public synchronized void bind(String name, Object obj) throws NamingException {
if (name == null) {
throw new IllegalArgumentException("Name required");
}
if (name.length() == 0) {
throw new InvalidNameException("Cannot bind object named after context");
}
// If it's an alias name, stop here.
if (aliases.containsKey(name)) {
throw new NameAlreadyBoundException("Name \"" + name + "\" already bound as an aliased name");
}
// Make sure it isn't bound anywhere
for (NamingEnumeration e = list(""); e.hasMore();) {
NameClassPair nameClassPair = (NameClassPair) e.next();
if (name.equals(nameClassPair.getName())) {
throw new NameAlreadyBoundException("Name \"" + name + "\" already bound by a managed subcontext");
}
}
doRebind(name, obj);
}
示例11: bindGlobals
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public void bindGlobals(final Map<String, Object> bindings) throws NamingException {
final Context containerSystemContext = containerSystem.getJNDIContext();
for (final Entry<String, Object> value : bindings.entrySet()) {
final String path = value.getKey();
// keep only global bindings
if (path.startsWith("module/") || path.startsWith("app/") || path.startsWith("comp/") || path.equalsIgnoreCase("global/dummy")) {
continue;
}
// a bit weird but just to be consistent if user doesn't lookup directly the resource
final Context lastContext = Contexts.createSubcontexts(containerSystemContext, path);
try {
lastContext.rebind(path.substring(path.lastIndexOf("/") + 1, path.length()), value.getValue());
} catch (final NameAlreadyBoundException nabe) {
nabe.printStackTrace();
}
containerSystemContext.rebind(path, value.getValue());
}
}
示例12: bind
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public void bind(String name, final Object obj) throws NamingException {
if(checkReadOnly()) {
return;
}
final int indx = name.indexOf(":");
if (indx > -1) {
/*
The ':' character will be in the path if its an absolute path name starting with the schema
'java:'. We strip the schema off the path before passing it to the node.resolve method.
*/
name = name.substring(indx + 1);
}
if (fastCache.containsKey(name)) {
throw new NameAlreadyBoundException();
} else {
final ParsedName parsedName = getParsedNameFor(name);
mynode.bind(parsedName, obj);
}
}
示例13: createSubcontext
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public Context createSubcontext(String name) throws NamingException {
if(checkReadOnly()) {
//TODO: null is fine if there is a one time - 10 calls will log a single time - log line (warning?)
return null;
}
final int indx = name.indexOf(":");
if (indx > -1) {
/*
The ':' character will be in the path if its an absolute path name starting with the schema
'java:'. We strip the schema off the path before passing it to the node.resolve method.
*/
name = name.substring(indx + 1);
}
if (fastCache.containsKey(name)) {
throw new NameAlreadyBoundException();
} else {
return mynode.createSubcontext(getParsedNameFor(name), readOnly);
}
}
示例14: unbind
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
public void unbind(final ParsedName name) throws NameAlreadyBoundException {
final int compareResult = name.compareTo(atomicHash);
if (compareResult == ParsedName.IS_EQUAL && name.getComponent().equals(atomicName)) {
if (name.next()) {
if (subTree != null) {
subTree.unbind(name);
}
} else {
unbound = true;
myObject = null;
parentTree.unbind(this);
}
} else if (compareResult == ParsedName.IS_LESS) {
if (lessTree != null) {
lessTree.unbind(name);
}
} else {//ParsedName.IS_GREATER ...
if (grtrTree != null) {
grtrTree.unbind(name);
}
}
}
示例15: createQueue
import javax.naming.NameAlreadyBoundException; //導入依賴的package包/類
@Override
public void createQueue(@NotNull final String name) throws io.amaze.bench.shared.jms.JMSException {
requireNonNull(name);
try {
internalCreateQueue(name);
} catch (NameAlreadyBoundException | JMSException e) {
throw new io.amaze.bench.shared.jms.JMSException(e);
}
}