Weblogic ---- Remote remote Call, weblogic ---- Remote
Write it again before deletion to prevent future forgetting.
I. Server Side
Package com. ij34.dao; import javax. ejb. remote;/*** @ author Admin * @ date Creation Time: 2:36:21 * @ version 1.0 * @ type_name Hello */@ Remote (value = Hellobean. class) public interface Hello {public String getHello (String name );}
Package com. ij34.dao; import java. util. date; import javax. ejb. stateless;/*** @ author Admin * @ date Creation Time: 2:36:42 * @ version 1.0 * @ type_name Hellobean */@ Stateless (mappedName = "mapHellobean ") public class Hellobean implements Hello {@ Override public String getHello (String name) {// TODO Auto-generated method stub return name + new Date ();}}
Export jar, put it in deployment, and then generate
Ii. Client
View jndi
Package com. ij34.bean; import java. util. properties; import javax. naming. context; import javax. naming. initialContext; import javax. naming. namingException; import com. ij34.dao. hello;/*** @ author Admin * @ date Creation Time: 2:47:47 * @ version 1.0 * @ type_name Test */public class Test {/*** @ param args */public static void main (String [] args) {// TODO Auto-generated method stub Properties properties = new Properties (); properties. setProperty (Context. INITIAL_CONTEXT_FACTORY, "weblogic. jndi. WLInitialContextFactory "); properties. setProperty (Context. PROVIDER_URL, "t3: // localhost: 7001"); try {Context ctx = new InitialContext (properties); Hello re = (Hello) ctx. lookup ("mapHellobean # com. ij34.dao. hello "); System. out. println (re. getHello ("Xi ,");} catch (NamingException e) {// TODO Auto-generated catch block e. printStackTrace ();}}}
Iii. Results