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


Java NamingException类代码示例

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


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

示例1: jndiDataSource

import javax.naming.NamingException; //导入依赖的package包/类
@Bean(destroyMethod="")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
    String jndiName = "java:comp/env/" + env.getProperty("sta.datasource.name", "jdbc/sensorThings");
    bean.setJndiName(jndiName);
    bean.setProxyInterface(DataSource.class);
    bean.setLookupOnStartup(false);
    bean.afterPropertiesSet();
    return (DataSource)bean.getObject();
}
 
开发者ID:kinota,项目名称:kinota-server,代码行数:11,代码来源:Application.java

示例2: main

import javax.naming.NamingException; //导入依赖的package包/类
public static void main(String[] args) throws NamingException {
	checkArgs(args);
	
	// Option is to use the WF context with no properties, this is not working because of JBEAP-xxxx at this moment
	InitialContext ic = new WildFlyInitialContext();
	
	Simple proxy = (Simple) ic.lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName());
	
	try {
		if(proxy.checkApplicationUser("admin")) {
			log.info("Expected 'admin'");
		} else {
			log.severe("Unexpected user, see server.log");
		}
	} catch (EJBException e) {
		throw e;
	}
}
 
开发者ID:wfink,项目名称:jboss-eap7.1-playground,代码行数:19,代码来源:WildFlyICConfigClient.java

示例3: getAttributeValue

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the required value
 *
 * @exception NamingException if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs)
    throws NamingException {

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving attribute " + attrId);

    if (attrId == null || attrs == null)
        return null;

    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return null;
    Object value = attr.get();
    if (value == null)
        return null;
    String valueString = null;
    if (value instanceof byte[])
        valueString = new String((byte[]) value);
    else
        valueString = value.toString();

    return valueString;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:32,代码来源:JNDIRealm.java

示例4: getName

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Get name.
 * 
 * @return Name value
 */
public String getName() {
	if (name != null)
		return name;
	if (attributes != null) {
		Attribute attribute = attributes.get(NAME);
		if (attribute != null) {
			try {
				name = attribute.get().toString();
			} catch (NamingException e) {
				// No value for the attribute
			}
		}
	}
	return name;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:ResourceAttributes.java

示例5: main

import javax.naming.NamingException; //导入依赖的package包/类
public static void main(String[] args) throws NamingException {
	checkArgs(args);
	
	Properties p = new Properties();
	
	p.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
	p.put(Context.PROVIDER_URL, "http-remoting://localhost:9080");
	
	p.put(Context.SECURITY_PRINCIPAL, "delegateUser");
	p.put(Context.SECURITY_CREDENTIALS, "delegateUser");
	InitialContext ic = new InitialContext(p);
	
	DelegateROC proxy = (DelegateROC) ic.lookup("ejb:EAP71-PLAYGROUND-MainServer-rocApp/ejb/DelegateROCBean!" + DelegateROC.class.getName());
	proxy.checkTransactionStickyness();
	
	// ic.close();  // not longer necessary
}
 
开发者ID:wfink,项目名称:jboss-eap7.1-playground,代码行数:18,代码来源:CheckDelegateTxROCClient.java

示例6: findRMIServer

import javax.naming.NamingException; //导入依赖的package包/类
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:RMIConnector.java

示例7: getETag

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Get ETag.
 * 
 * @param strong If true, the strong ETag will be returned
 * @return ETag
 */
public String getETag(boolean strong) {
    String result = null;
    if (attributes != null) {
        Attribute attribute = attributes.get(ETAG);
        if (attribute != null) {
            try {
                result = attribute.get().toString();
            } catch (NamingException e) {
                ; // No value for the attribute
            }
        }
    }
    if (strong) {
        // The strong ETag must always be calculated by the resources
        result = strongETag;
    } else {
        // The weakETag is contentLenght + lastModified
        if (weakETag == null) {
            weakETag = "W/\"" + getContentLength() + "-" 
                + getLastModified() + "\"";
        }
        result = weakETag;
    }
    return result;
}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:32,代码来源:ResourceAttributes.java

示例8: getUserIdentity

import javax.naming.NamingException; //导入依赖的package包/类
private String getUserIdentity(final DirContextOperations ctx) {
    final String identity;

    if (useDnForUserIdentity) {
        identity = ctx.getDn().toString();
    } else {
        final Attribute attributeName = ctx.getAttributes().get(userIdentityAttribute);
        if (attributeName == null) {
            throw new AuthorizationAccessException("User identity attribute [" + userIdentityAttribute + "] does not exist.");
        }

        try {
            identity = (String) attributeName.get();
        } catch (NamingException e) {
            throw new AuthorizationAccessException("Error while retrieving user name attribute [" + userIdentityAttribute + "].");
        }
    }

    return IdentityMappingUtil.mapIdentity(identity, identityMappings);
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:21,代码来源:LdapUserGroupProvider.java

示例9: restoreEnvironmentParameter

import javax.naming.NamingException; //导入依赖的package包/类
private void restoreEnvironmentParameter(DirContext context, String parameterName,
		Hashtable<?, ?> preservedEnvironment) {
	try {
		context.removeFromEnvironment(parameterName);
		if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
			context.addToEnvironment(parameterName, preservedEnvironment.get(parameterName));
		}
	} catch (NamingException e) {
		// Ignore
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:JNDIRealm.java

示例10: defineTriggerExecutionSpecificPoint

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Defines the Administration point and administrative role for the TriggerExecution specific point
 * @param apCtx The administrative point context
 * @throws NamingException If the operation failed
 */
public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
{
    Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
    Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
    
    if ( administrativeRole == null
        || !AttributeUtils.containsValueCaseIgnore( administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA ) )
    {
        Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
            SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true );
        apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:TriggerUtils.java

示例11: lookup

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Retrieves the named object.
 * 
 * @param name the name of the object to look up
 * @return the object bound to name
 * @exception NamingException if a naming exception is encountered
 */
public Object lookup(String name)
    throws NamingException {
    // Strip the URL header
    // Find the appropriate NamingContext according to the current bindings
    // Execute the lookup on that context
    return getBoundContext().lookup(parseName(name));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SelectorContext.java

示例12: getEJB

import javax.naming.NamingException; //导入依赖的package包/类
protected <T> T getEJB(Class<T> klass){
    try {
        return (T) ctx.lookup("java:global/classes/"+klass.getSimpleName()+"!"+klass.getName());
    } catch (NamingException e) {
        return null;
    }
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:8,代码来源:TopUsersTest.java

示例13: removeResource

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Set the specified resources in the naming context.
 */
public void removeResource(String name) {

    try {
        envCtx.unbind(name);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.unbindFailed", e));
    }

    ObjectName on = objectNames.get(name);
    if (on != null) {
        Registry.getRegistry(null, null).unregisterComponent(on);
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:18,代码来源:NamingContextListener.java

示例14: getReference

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Retrieves the Reference of this object.
 *
 * @return The non-null Reference of this object.
 * @exception NamingException If a naming exception was encountered
 *          while retrieving the reference.
 */
public Reference getReference() throws NamingException {
    String    cname = "org.hsqldb.jdbc.JDBCDataSourceFactory";
    Reference ref   = new Reference(getClass().getName(), cname, null);

    ref.add(new StringRefAddr("database", source.getDatabase()));
    ref.add(new StringRefAddr("user", source.getUser()));
    ref.add(new StringRefAddr("password", source.password));
    ref.add(new StringRefAddr("loginTimeout",
                              Integer.toString(source.loginTimeout)));
    ref.add(new StringRefAddr("poolSize", Integer.toString(connections.length)));

    return ref;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:21,代码来源:JDBCPool.java

示例15: checkWritable

import javax.naming.NamingException; //导入依赖的package包/类
/**
 * Throws a naming exception is Context is not writable.
 */
protected boolean checkWritable() throws NamingException {
	if (isWritable()) {
		return true;
	} else {
		if (exceptionOnFailedWrite) {
			throw new javax.naming.OperationNotSupportedException(sm.getString("namingContext.readOnly"));
		}
	}
	return false;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:14,代码来源:NamingContext.java


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