亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? client.java

?? EJB_原代碼多例-好好東西啊
?? JAVA
字號(hào):
package com.wiley.compBooks.roman.session.fazuul;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.*;
import java.io.*;

/**
 * Client for Fazuul Game.
 */
public class Client {

	public static void main(String[] args) {

		new Client().start();
	}

	// Current list of Component EJB Objects I own
	private Vector components = new Vector();

	// A Machine which dispenses Component EJB Objects
	private Machine machine;

	/**
	 * Starts the game.  The main game loop is here.
	 */
	public void start() {

		try {
			/*
			 * Get System properties for JNDI initialization
			 */
			Properties props = System.getProperties();

			/*
			 * Get a reference to the MachineHome Object - the
			 * factory for Machine EJB Objects
			 */
			Context ctx = new InitialContext(props);
			MachineHome home = (MachineHome) ctx.lookup("MachineHome");

			/*
			 * Use the factory to create the Machine EJB Object 
			 */
			machine = home.create();
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}

		/*
		 * Start reading input from standard input
		 */	
		String line = null, command = null, args = null;
		StringTokenizer tokens = null;
                BufferedReader reader = new BufferedReader(new InputStreamReader (System.in));

                while (true) {

			/*
			 * Print prompt, read next input line, and get command
			 */
			try {
				System.out.println();
				System.out.print("> ");
                        	line = reader.readLine();
				System.out.println();
                        	tokens = new StringTokenizer(line, " ", false);
                       		// Get command.  e.g. "attach" or "inv" 
				command = tokens.nextToken();

				// Get arguments to command.
				args = null;
				if (tokens.hasMoreElements()) {
					args = line.substring(command.length()+1, line.length());
				}
			}
			catch (Exception e) {
				continue;
			}
		
			/*
			 * Do case analysis based upon command.
			 */
			try {
				/*
				 * If the user wants to examine a component
				 */
				if (command.equals("examine")) {
					examine(args);
				}

				/*
				 * If user wants to attach 2 components,
				 * then extract the 2 component names from
				 * the argument string, and call attach()
				 */
				else if (command.equals("attach")) {
					String item1 = null, item2 = null;
					try {
						StringTokenizer argtokens = new StringTokenizer(args, " ");
						item1 = argtokens.nextToken();
						argtokens.nextToken();
						item2 = argtokens.nextToken();
					}
					catch (Exception e) {
						throw new Exception("Syntax: attach <item1> to <item2>");
					}

					attach(item1, item2);
				}
				/*
				 * If the user wants to discard an object
				 */
				else if (command.equals("drop")) {
					drop(args);
				}
				/*
				 * If the user needs more components
				 */
				else if (command.equals("gimme")) {
					gimme();
				}
				/*
				 * If the user wants to list the components
				 * he has.
				 */
				else if (command.equals("inv")) {
					inv();
				}
				/*
				 * If the user wants to end the game
				 */
				else if (command.equals("quit")) {
					quit();
				}
				/*
				 * If the user wants to suspend the game
				 */
				else if (command.equals("suspend")) {
					if (args == null) {
						System.out.println("Please specify a filename.");
					}
					else {
						suspend(args);
					}
				}
				/*
				 * If the user wants to resume a suspended
				 * game.
				 */
				else if (command.equals("resume")) {
					if (args == null) {
						System.out.println("Please specify a filename.");
					}
					else {
						resume(args);
					}
				}


				else {
					System.out.println("Syntax: [attach <item1> to <item2> | examine <item> | inv | gimme | drop <item> | suspend <filename> | resume <filename> | quit]");
				}
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * Suspends the game.  Writes the current game state to disk
	 * via EJB object handles.
	 */
	private void suspend(String filename) {

		ObjectOutputStream stream = null;

		try {
			stream = new ObjectOutputStream(
				new FileOutputStream(filename));

			for (int i=0; i < components.size(); i++) {
				Component comp = (Component) components.elementAt(i);
				Handle handle = comp.getHandle();
				stream.writeObject(handle);
			}

			stream.flush();
		
			System.out.println("Game saved.");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			if (stream != null) {
				try { stream.close(); } catch (Exception e) {}
			}
		}

		System.exit(0);
	}


	/**
	 * Resumes a suspended game via EJB object handles. 
	 */
	private void resume(String filename) {
	
		clearComps();

		ObjectInputStream stream = null;

		try {
			stream = new ObjectInputStream(
				new FileInputStream(filename));

			while (true) {
				Handle handle = (Handle) stream.readObject();
				
				components.addElement(
					(Component) handle.getEJBObject());
			}
		}
		catch (EOFException e) {
			System.out.println("Game loaded.");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			if (stream != null) {
				try { stream.close(); } catch (Exception e) {}
			}
		}
	}

	/*
	 * Removes all components the user has.
	 */
	private void clearComps() {

		System.out.println("Clearing game state...");

		for (int i=0; i < components.size(); i++) {
			try {
				Component comp =
					(Component) components.elementAt(i);

				comp.remove();
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}

		components = new Vector();
	}

	/**
	 * Quits the game, cleaning up all EJB Objects.
	 */
	private void quit() {

		/*
		 * 1: Remove all components
		 */
		clearComps();

		/*
		 * 2: Remove machine
		 */
		try {
			machine.remove();
		}
		catch (Exception e) {
			e.printStackTrace();
		}

		System.exit(0);
	}

	/**
	 * Gets more components from the machine
	 */
	private void gimme() throws Exception {
		for (int i=0; i < 3; i++) {
			Component comp = machine.makeComponent();
			components.addElement(comp);
			System.out.println("The machine pops out a " + comp.getName());
		}
	}

	/**
	 * Drops a component.
	 */
	private void drop(String componentName) throws Exception {
		for (int i=0; i < components.size(); i++) {
			Component comp = (Component) components.elementAt(i);
			if (comp.getName().equals(componentName)) {
				// Call remove() on EJB Object
				comp.remove();

				components.removeElement(comp);
				System.out.println("You dropped your " + componentName);
				return;
			}
		}
	}

	/**
	 * Lists the inventory of components I currently have.
	 */
	private void inv() throws Exception {
		for (int i=0; i < components.size(); i++) {
			Component comp = (Component) components.elementAt(i);
			System.out.println(comp.getName());
		}
	}

	/**
	 * Prints out the description of component with name componentName.
	 */
	private void examine(String componentName) throws Exception {
		/*
		 * Loop through all the components.  Get the names of each
		 * component.  If the name matches, then print out that
		 * component's description.
		 */
		for (int i=0; i < components.size(); i++) {
			Component comp = (Component) components.elementAt(i);
			if (comp.getName().equals(componentName)) {
				System.out.println(comp.getDescription());
				return;
			}
		}	
	}

	/**
	 * Attempts to attach components with names A and B together.
	 */
	private void attach(String componentNameA, String componentNameB) throws Exception {
		Component componentA = null, componentB = null;

		/*
		 * Loop through all the components.  Get the Names of each
		 * component.  If the name matches, then that's our Component A.
		 */
		for (int i=0; i < components.size(); i++) {
			Component comp = (Component) components.elementAt(i);
			if (comp.getName().equals(componentNameA)) {
				componentA = comp;
			}
		}
	
		/*
		 * Print out some error codes if we didn't find any matches
		 */
		if (componentA == null) {
			System.out.println("You don't have a " + componentNameA);
			return;
		}
	
		/*
		 * Loop through all the components.  Get the Names of each
		 * component.  If the name matches, AND it's not the same
		 * as the Component A above, then that's our Component B.
		 */
		for (int i=0; i < components.size(); i++) {
			Component comp = (Component) components.elementAt(i);
			if (comp.getName().equals(componentNameB)
				&& (!comp.equals(componentA))) {
				componentB = comp;
			}
		}

		/*
		 * Print out some error codes if we didn't find any matches
		 */
		if (componentB == null) {
			System.out.println("You don't have a " + componentNameB);
			return;
		}

		/*
		 * Try to attach the two components.  If they attach,
		 * 1) Remove the old Component EJB Objects
		 * 2) Remove the old Components from our list of components
		 * 3) Add the new, combined component to our list
		 */
		try {
			Component newComp = componentA.attachTo(componentB);

			// Remove the two old Components' EJB Object
			componentA.remove();
			componentB.remove();

			components.removeElement(componentA);
			components.removeElement(componentB);
			components.addElement(newComp);

			System.out.println("Fitting the " + componentNameA + " into the " + componentNameB + ", out pops a " + newComp.getName() + "!");
		}
		/*
		 * If an application-level exception occurs (i.e. if
		 * the two components won't attach) then handle it.
		 * Let the main loop handle system-level exceptions.
		 */
		catch (ComponentException e) {
			System.out.println(e.toString());
		}
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品女同一区二区三区| 欧美日韩国产综合一区二区三区 | 欧美国产日本视频| 国产一区二区三区最好精华液| 欧美www视频| 国产一区二区三区| 中文字幕电影一区| 色婷婷久久一区二区三区麻豆| 亚洲国产日韩精品| 日韩一级成人av| 国产美女精品一区二区三区| 国产精品久久三| 在线视频中文字幕一区二区| 天堂在线亚洲视频| 久久久久久**毛片大全| 色综合久久六月婷婷中文字幕| 亚洲成人激情自拍| 久久精品一区二区三区不卡牛牛 | 婷婷成人综合网| 久久综合丝袜日本网| 99精品视频一区二区| 天堂午夜影视日韩欧美一区二区| 精品免费日韩av| 成人免费电影视频| 偷拍亚洲欧洲综合| 中文字幕欧美国产| 欧美日韩在线播放三区四区| 国产一本一道久久香蕉| 一区二区三区精品在线观看| 91精品国产综合久久福利软件| 国产福利91精品| 午夜视频一区二区| 国产精品美女久久久久aⅴ| 欧美日韩一区二区三区在线 | 丁香天五香天堂综合| 亚洲一区在线观看网站| 国产亚洲精品久| 欧美日本韩国一区二区三区视频 | 亚洲婷婷国产精品电影人久久| 欧美日韩免费观看一区二区三区| 国产一区视频导航| 亚洲成av人片一区二区梦乃| 国产欧美一区二区精品秋霞影院| 欧美日韩免费一区二区三区 | 日本高清成人免费播放| 国产一区二区视频在线| 日韩中文字幕一区二区三区| 中文字幕亚洲一区二区va在线| 日韩视频免费观看高清完整版 | 欧美色精品在线视频| 国产成人免费网站| 久久精品国产77777蜜臀| 亚洲高清中文字幕| 综合av第一页| 国产精品视频九色porn| 亚洲人成伊人成综合网小说| 精品精品国产高清一毛片一天堂| 欧美在线观看一区二区| 91免费视频网| www.激情成人| 国产成人免费在线| 国产精品综合二区| 美女高潮久久久| 日韩精品乱码免费| 一二三四社区欧美黄| 国产精品福利一区二区三区| 国产视频在线观看一区二区三区| 欧美xxxxxxxx| 日韩精品中文字幕在线不卡尤物| 制服丝袜成人动漫| 欧美日韩精品免费观看视频| 欧美视频日韩视频在线观看| 日本高清不卡一区| 欧美亚洲国产一区在线观看网站| 99久久婷婷国产综合精品电影| 成人久久久精品乱码一区二区三区| 国产激情精品久久久第一区二区 | 一级中文字幕一区二区| 亚洲人成在线播放网站岛国| 亚洲精品国产无套在线观| 亚洲免费大片在线观看| 亚洲欧美一区二区三区久本道91 | 亚洲精品国产成人久久av盗摄| 综合色天天鬼久久鬼色| 亚洲欧美色图小说| 亚洲美女在线国产| 亚洲香肠在线观看| 亚洲va韩国va欧美va精品| 午夜精品福利一区二区蜜股av| 午夜精品久久久久久久| 久久99精品一区二区三区| 国产在线精品一区二区| 国产精品123区| av在线不卡电影| 日本道免费精品一区二区三区| 欧美影视一区在线| 制服丝袜激情欧洲亚洲| 欧美成人女星排名| 国产农村妇女毛片精品久久麻豆 | 一区二区免费视频| 日韩中文欧美在线| 国模大尺度一区二区三区| 国产精品一区二区你懂的| av不卡免费在线观看| 欧美男人的天堂一二区| 久久老女人爱爱| 自拍偷自拍亚洲精品播放| 性感美女久久精品| 国产精品亚洲第一| 色女孩综合影院| 欧美成人精品3d动漫h| 国产精品久久精品日日| 亚洲一二三级电影| 韩国精品免费视频| 91成人在线精品| 久久综合九色综合97婷婷女人| 亚洲手机成人高清视频| 六月丁香婷婷久久| 色综合天天综合在线视频| 9191精品国产综合久久久久久| 久久夜色精品国产欧美乱极品| ...中文天堂在线一区| 日韩精品电影在线观看| 国产精品伊人色| 欧美日韩国产高清一区二区三区 | 久久免费的精品国产v∧| 亚洲欧美一区二区三区久本道91 | 国产精品66部| 欧美巨大另类极品videosbest | 国产传媒欧美日韩成人| 欧美日韩精品综合在线| 国产精品人妖ts系列视频| 日韩中文字幕不卡| 91国偷自产一区二区三区成为亚洲经典 | 亚洲国产精品t66y| 日本网站在线观看一区二区三区 | 日韩欧美一区二区三区在线| 亚洲婷婷在线视频| 国产麻豆91精品| 欧美日韩不卡一区二区| 欧美国产一区二区| 久久99国内精品| 欧美久久久久中文字幕| 亚洲精品自拍动漫在线| 国产成人免费网站| 日韩欧美一区二区三区在线| 亚洲最色的网站| www.色精品| 日本一二三不卡| 久久精品国产久精国产| 欧美精品在线视频| 亚洲欧美电影一区二区| 国产精品1区2区3区在线观看| 精品国产一区二区三区久久影院| 亚洲成av人片| 欧美视频三区在线播放| 一区二区三区资源| 欧洲精品一区二区| 亚洲狼人国产精品| 91成人免费电影| 日韩毛片高清在线播放| 波多野洁衣一区| 国产精品蜜臀在线观看| 成人app下载| 国产精品成人免费| kk眼镜猥琐国模调教系列一区二区| 久久久久88色偷偷免费| 国产美女一区二区| 久久久久久电影| 丁香婷婷综合色啪| 亚洲婷婷综合色高清在线| 色综合天天在线| 亚洲国产一区二区视频| 欧美日韩精品是欧美日韩精品| 亚洲成人高清在线| 91精品国产入口| 国产在线视频不卡二| 国产日韩欧美精品一区| 国产99久久久久| 亚洲免费在线看| 欧美日韩国产中文| 日本特黄久久久高潮| 精品精品国产高清a毛片牛牛| 国产精品香蕉一区二区三区| 国产精品美女久久久久久久网站| 北岛玲一区二区三区四区| 亚洲三级电影网站| 欧美视频日韩视频在线观看| 日本不卡的三区四区五区| 欧美成人性战久久| 国产91综合一区在线观看| 最新成人av在线| 91超碰这里只有精品国产| 国产一区二区精品久久91| 国产精品久久久久久久久图文区| 91免费视频观看| 日韩二区在线观看| 国产日韩精品一区二区浪潮av| 91丨九色丨尤物| 三级久久三级久久久|