本文整理汇总了Java中javax.naming.Binding类的典型用法代码示例。如果您正苦于以下问题:Java Binding类的具体用法?Java Binding怎么用?Java Binding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Binding类属于javax.naming包,在下文中一共展示了Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configFromJndiConf
import javax.naming.Binding; //导入依赖的package包/类
private void configFromJndiConf(Object rootContextName) {
if (rootContextName instanceof String) {
String name = (String) rootContextName;
name = name.substring(0, name.lastIndexOf('/')) + "/conf" + name.substring(name.lastIndexOf('/'));
try {
InitialContext ctx = new InitialContext();
NamingEnumeration<Binding> bindings = ctx.listBindings(name);
while (bindings.hasMore()) {
Binding bd = bindings.next();
IntrospectionSupport.setProperty(this, bd.getName(), bd.getObject());
}
} catch (Exception ignored) {
if (LOG.isTraceEnabled()) {
LOG.trace("exception on config from jndi: " + name, ignored);
}
}
}
}
示例2: listCollectionPaths
import javax.naming.Binding; //导入依赖的package包/类
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths(Set<String> set,
DirContext resources, String path) throws NamingException {
Enumeration<Binding> childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = childPaths.nextElement();
String name = binding.getName();
StringBuilder childPath = new StringBuilder(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例3: listBindings
import javax.naming.Binding; //导入依赖的package包/类
/**
* Enumerates the names bound in the named context, along with the
* objects bound to them. The contents of any subcontexts are not
* included.
* <p>
* If a binding is added to or removed from this context, its effect on
* an enumeration previously returned is undefined.
*
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
// Removing empty parts
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty()) {
return new NamingContextBindingsEnumeration(bindings.values().iterator(), this);
}
NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name, name.get(0)));
}
if (entry.type != NamingEntry.CONTEXT) {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
return ((Context) entry.value).listBindings(name.getSuffix(1));
}
示例4: doGet
import javax.naming.Binding; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain;UTF-8");
PrintWriter out = resp.getWriter();
try {
Context ctx = new InitialContext();
NamingEnumeration<Binding> enm =
ctx.listBindings("java:comp/env/list");
while (enm.hasMore()) {
Binding b = enm.next();
out.print(b.getObject().getClass().getName());
}
} catch (NamingException ne) {
ne.printStackTrace(out);
}
}
示例5: while
import javax.naming.Binding; //导入依赖的package包/类
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths
(Set set, DirContext resources, String path)
throws NamingException {
Enumeration childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = (Binding) childPaths.nextElement();
String name = binding.getName();
StringBuffer childPath = new StringBuffer(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例6: listPaths
import javax.naming.Binding; //导入依赖的package包/类
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listPaths(Set set, DirContext resources, String path)
throws NamingException {
Enumeration childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = (Binding) childPaths.nextElement();
String name = binding.getName();
String childPath = path + "/" + name;
set.add(childPath);
Object object = binding.getObject();
if (object instanceof DirContext) {
listPaths(set, resources, childPath);
}
}
}
示例7: listCollectionPaths
import javax.naming.Binding; //导入依赖的package包/类
/**
* List resource paths (recursively), and store all of them in the given
* Set.
*/
private static void listCollectionPaths(Set<String> set, DirContext resources, String path) throws NamingException {
Enumeration<Binding> childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
Binding binding = childPaths.nextElement();
String name = binding.getName();
StringBuilder childPath = new StringBuilder(path);
if (!"/".equals(path) && !path.endsWith("/"))
childPath.append("/");
childPath.append(name);
Object object = binding.getObject();
if (object instanceof DirContext) {
childPath.append("/");
}
set.add(childPath.toString());
}
}
示例8: listBindings
import javax.naming.Binding; //导入依赖的package包/类
/**
* Enumerates the names bound in the named context, along with the objects
* bound to them. The contents of any subcontexts are not included.
* <p>
* If a binding is added to or removed from this context, its effect on an
* enumeration previously returned is undefined.
*
* @param name
* the name of the context to list
* @return an enumeration of the bindings in this context. Each element of
* the enumeration is of type Binding.
* @exception NamingException
* if a naming exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
// Removing empty parts
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty()) {
return new NamingContextBindingsEnumeration(bindings.values().iterator(), this);
}
NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0)));
}
if (entry.type != NamingEntry.CONTEXT) {
throw new NamingException(sm.getString("namingContext.contextExpected"));
}
return ((Context) entry.value).listBindings(name.getSuffix(1));
}
示例9: init
import javax.naming.Binding; //导入依赖的package包/类
public void init() throws ServletException {
super.init();
// Nombre del layout por defecto
defaultLayoutName = getServletConfig().getInitParameter("defaultLayoutName");
try {
Context context = new InitialContext();
// Bajo JNDI habr� todos los pares: nombre, path que metemos en el Map
NamingEnumeration namingEnum = context.listBindings("java:comp/env/layout");
while (namingEnum.hasMore()) {
Binding binding = (Binding) namingEnum.next();
layoutPathMap.put(binding.getName(), binding.getObject());
}
} catch (NamingException e) {
log.error("Error accediendo a JNDI", e);
}
// El layout por defecto debe estar en el Map!
if (!layoutPathMap.containsKey(defaultLayoutName)) {
log.error("El layout por defecto \"" + defaultLayoutName + "\" no est� definido bajo java:comp/env/layout");
throw new UnavailableException("Error de configuraci�n");
}
}
示例10: listServices
import javax.naming.Binding; //导入依赖的package包/类
private void listServices(BundleContext bundleContext, Context context) throws NamingException {
Dictionary<String, Object> propertyMap = new Hashtable<>();
propertyMap.put("osgi.jndi.service.name", "foo/myService");
FooService fooService = new FooServiceImpl();
ServiceRegistration<FooService> fooServiceRegistration = bundleContext.registerService(
FooService.class, fooService, propertyMap);
NamingEnumeration<Binding> listBindings =
context.listBindings("osgi:service/foo/myService");
Binding binding = listBindings.nextElement();
logger.info("First service retrieved from the listBinding has the class : " + binding.getClassName());
listBindings.close(); //call the close() method so that it will unget all the gotten services.
fooServiceRegistration.unregister();
}
示例11: listBindings
import javax.naming.Binding; //导入依赖的package包/类
/**
* Enumerates the names bound in the named context, along with the
* objects bound to them. The contents of any subcontexts are not
* included.
* <p>
* If a binding is added to or removed from this context, its effect on
* an enumeration previously returned is undefined.
*
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
* @throws NamingException if a jndi exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
// Removing empty parts
while ((!name.isEmpty()) && (name.get(0).length() == 0)) {
name = name.getSuffix(1);
}
if (name.isEmpty()) {
return new NamingContextBindingsEnumeration(new ArrayList<>(bindings.values()), this);
}
NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException(SM.getString("namingContext.nameNotBound", name, name.get(0)));
}
if (entry.type != NamingEntry.CONTEXT) {
throw new NamingException(SM.getString("namingContext.contextExpected"));
}
return ((Context) entry.value).listBindings(name.getSuffix(1));
}
示例12: listContext
import javax.naming.Binding; //导入依赖的package包/类
/**
* Recursively exhaust the JNDI tree
*/
private static final void listContext(javax.naming.Context ctx, String indent) {
try {
NamingEnumeration<Binding> list = ctx.listBindings("");
while (list.hasMore()) {
Binding item = (Binding) list.next();
String className = item.getClassName();
String name = item.getName();
log.info(indent + className + " | " + name);
Object o = item.getObject();
if (o instanceof javax.naming.Context) {
listContext((javax.naming.Context) o, indent + " ");
}
}
} catch (NamingException ex) {
log.warn("JNDI failure: ", ex);
}
}
示例13: changePassord
import javax.naming.Binding; //导入依赖的package包/类
public void changePassord(ServiceContext serviceContext, User user, String password) throws Exception{
long companyId = serviceContext.getCompanyId();
Properties userMappings = getUserMappings(serviceContext.getCompanyId());
Binding binding = getUser(companyId, user.getScreenName());
System.out.println("bingging " + binding);
System.out.println("Pass " + user.getPassword());
String name = StringPool.BLANK;
StringBuilder sb = new StringBuilder();
LdapContext ctx = getContext(serviceContext.getCompanyId());
sb = new StringBuilder();
sb.append(userMappings.getProperty("screenName"));
sb.append(StringPool.EQUAL);
sb.append(user.getScreenName());
sb.append(StringPool.COMMA);
sb.append(getUsersDN(companyId));
name = sb.toString();
Modifications mods = Modifications.getInstance();
mods.addItem(userMappings.getProperty(UserConverterKeys.PASSWORD),password);
ModificationItem[] modItems = mods.getItems();
if (binding != null) {
ctx.modifyAttributes(name, modItems);
}
}
示例14: getNameInNamespace
import javax.naming.Binding; //导入依赖的package包/类
public String getNameInNamespace(long companyId, Binding binding)
throws Exception {
String baseDN = PrefsPropsUtil.getString(companyId,
PropsKeys.LDAP_BASE_DN);
if (Validator.isNull(baseDN)) {
return binding.getName();
} else {
StringBuilder sb = new StringBuilder();
sb.append(binding.getName());
sb.append(StringPool.COMMA);
sb.append(baseDN);
return sb.toString();
}
}
示例15: next
import javax.naming.Binding; //导入依赖的package包/类
@Override
public Binding next() throws NamingException {
if (hasMore()) {
final Entry<String, Object> entry = iterator.next();
final String name = entry.getKey();
Object value = entry.getValue();
try {
value = NamingManager.getObjectInstance(value, new CompositeName().add(name), context, environnement);
} catch (final Throwable err) {
final NamingException errNaming = new NamingException("Failed To Get Instance ");
errNaming.setRootCause(err);
throw errNaming;
}
return new Binding(name, value);
}
throw new NoSuchElementException();
}