Innaz Review, Samsung Galaxy, price and specifications, Flash Android, Games For Your Apple, Jailbreak Tool For iOS, IMEI Unlock Method

Selasa, 20 Maret 2007

Print JNDI tree

Print JNDI tree - In the past, when I started to start blogging, many thoughts disturbed me. I want to have a blog with a nice and interesting look. I am constantly looking for basic tutorials from some web and blogs on the internet. And thankfully, one by one I started to do it, and of course have to go through some confusion process first, but the most important of a blog that is content, yes on the blog Innaz Review we will discuss a lot of information about gadgets that are very in need by you, now we will discuss first about Print JNDI tree please refer to the information we will convey until completion:

Articles : Print JNDI tree
full Link : Print JNDI tree

You can also see our article on:


Print JNDI tree

At one point or another most of us would have wanted to see what was in the JNDI tree of the Application Server. This may have been because of a javax.naming.NameNotFoundException thrown by the application under development.

After scouring the internet and not finding a way to do this seemingly simple task, I put this together in about an hours time.


import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;

public class JNDITree {
private Context context = null;

public static void main(String[] args) throws Exception {
new JNDITree().printJNDITree("");
System.out.println("DONE");
}

public JNDITree() throws NamingException {
setEnv();
}

/* Please modify this method or comment and use jndi.properties
*/
public void setEnv() throws NamingException {
Hashtable env = new Hashtable();
//OC4J
// env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
// env.put(Context.PROVIDER_URL, "ormi://172.16.x.x:12404");
// env.put(Context.SECURITY_PRINCIPAL, "admin");
// env.put(Context.SECURITY_CREDENTIALS, "welcome");
//JBOSS
// env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
// env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
// env.put(Context.PROVIDER_URL, "jnp://172.16.x.x:1099");
//WEBLOGIC
// env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
// env.put(Context.PROVIDER_URL, "t3://172.16.x.x:7001");


context = new InitialContext(env);
}

public void printJNDITree(String ct) {
try {
printNE(context.list(ct), ct);
} catch (NamingException e) {
//ignore leaf node exception
}
}

private void printNE(NamingEnumeration ne, String parentctx) throws NamingException {
while (ne.hasMoreElements()) {
NameClassPair next = (NameClassPair) ne.nextElement();
printEntry(next);
increaseIndent();
printJNDITree((parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName());
decreaseIndent();
}
}

private void printEntry(NameClassPair next) {
System.out.println(printIndent() + "-->" + next);
}


private int indentLevel = 0;

private void increaseIndent() {
indentLevel += 4;
}

private void decreaseIndent() {
indentLevel -= 4;
}

private String printIndent() {
StringBuffer buf = new StringBuffer(indentLevel);
for (int i = 0; i < indentLevel; i++) {
buf.append(" ");
}
return buf.toString();
}



This seemed to have worked very well for me and I thought I'd share it incase any of you have the same need.
In case anyone has a better way of doing this, kindly comment.

P.S. Dont forget to edit the setEnv() method to set the InitialContext. Default values have been given for a few App Servers.
Alternatively, comment the method out and use jndi.properties with values corresponding to your application server.



so much information Print JNDI tree

hopefully Print JNDI tree information can provide benefits for you in determining the gadgets that fit your needs in daily life.

you just read Print JNDI tree if you feel this information is useful and want to bookmark or share it please use link https://innaz2.blogspot.com/2007/03/print-jndi-tree.html if you want more information please search on other pages this blog.

Tag :
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : Print JNDI tree

2 komentar:

  1. pug puppies for sale,pug puppies for sale near me
    teacup pugs for sale,teacup pugs,teacup pug puppies for sale,teacup pug for sale near me,pug for sale near me,pug puppies for sale under,teacup pugs,pug puppies near me,teacup pugs,teacup pug puppies for sale,pug puppy for sale,mini pug,baby pugs for sale,pug breeders near me,pugs puppies for sale,black pug puppies for sale,miniature pug,pug puppies,pugs for sale near me,pugs for sale near me,pugs puppies,teacup pug puppies for sale,pugs for sale,baby pugs for sale
    french bulldog pupies for sale
    pug puppies for sale
    pug puppy for sale near me
    French Bulldog Puppy for sale near me
    teacup puppies for sale near me
    Pug puppies for sale
    pugs for sale
    teacup pug puppies for sale
    teacup pug puppies for sale

    BalasHapus