⇤ ← Revision 1 as of 2014-06-10 21:24:29
Size: 1334
Comment:
|
Size: 1671
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 14: | Line 14: |
{{{ | File test/Client.java {{{#!highlight java |
Line 16: | Line 17: |
Line 21: | Line 21: |
import org.allowed.bitarus.IWSTest; | |
Line 29: | Line 30: |
env.put(Context.PROVIDER_URL, "jnp://myserver.example.com:1099"); | env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099"); |
Line 31: | Line 32: |
WSTest test = (WSTest) context.lookup("WSTest/remote"); | IWSTest test = (IWSTest) context.lookup("WSTest/remote"); System.out.println( test.helloWorld() ); |
Line 36: | Line 38: |
Build: * cd test #package folder * javac -cp .:test2-0.0.1.jar Client.java Run: *java -cp .:/opt/jboss-5.1.0.GA/client/*:test/test2-0.0.1.jar test/Client # JBoss client Jars, EJB with interface IWSTest |
JNDI
JNDI is a standard Java API that is bundled with JDK1.3 and higher. JNDI provides a common interface to a variety of existing naming services: DNS, LDAP, Active Directory, RMI registry, COS registry, NIS, and file systems.
http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch3.chapter.html
Sample
Properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
- java.naming.provider.url=jnp://localhost:1099
- java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
File test/Client.java
1 package test;
2 import java.security.Security;
3 import java.util.Properties;
4 import javax.naming.Context;
5 import javax.naming.InitialContext;
6 import org.allowed.bitarus.IWSTest;
7
8 public class Client
9 {
10 public static void main(String args[]) throws Exception
11 {
12 Properties env = new Properties();
13 env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
14 env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
15 env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
16 InitialContext context = new InitialContext(env);
17 IWSTest test = (IWSTest) context.lookup("WSTest/remote");
18 System.out.println( test.helloWorld() );
19 }
20 }
Build:
- cd test #package folder
- javac -cp .:test2-0.0.1.jar Client.java
Run:
- java -cp .:/opt/jboss-5.1.0.GA/client/*:test/test2-0.0.1.jar test/Client # JBoss client Jars, EJB with interface IWSTest