Weblogic ---- Remote remote Call, weblogic ---- Remote

Source: Internet
Author: User

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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.