pricerclient.java

来自「EJB3.0请一定要上载质量高而且本站没有的源码」· Java 代码 · 共 37 行

JAVA
37
字号
package examples.stateless.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import examples.stateless.interfaces.PricerInjection;
import examples.stateless.interfaces.PricerLookup;

public class PricerClient {
	public static void main(String[] args) {
		try {
			InitialContext ic = new InitialContext();

			// Prefixing the name with the pound sign (#) is a convention of Glassfish
			// when using multiple interfaces to make up the business interface. The 
			// specification is unclear on how clients should lookup beans that implement
			// more than one interface.
			
			PricerLookup pricerLookup = (PricerLookup)ic.lookup("#"+PricerLookup.class.getName());
			PricerInjection pricerInjection = (PricerInjection)ic.lookup("#"+PricerInjection.class.getName());
			//PricerLookup pricerLookup = (PricerLookup)ic.lookup(PricerLookup.class.getName());
			//PricerInjection pricerInjection = (PricerInjection)ic.lookup(PricerInjection.class.getName());
			//Pricer pricerLookup = (Pricer)ic.lookup(Pricer.class.getName());
			//Pricer pricerInjection = pricerLookup;

			System.out.println("Tax (using lookup) on: 8.5 for State: ny is: "+
					pricerLookup.getTaxLookup(8.5,"ny"));
			
			System.out.println("Tax (using injection) on: 8.5 for State: ny is: "+
					pricerInjection.getTaxInjection(8.5,"ny"));
		} 
		catch (NamingException e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?