⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ejbbeanmanager.java

📁 this is example use EJB with jboss.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			JResult ret = open();
			if(ret.isSucceeded()){
				nodeHelper =dbServerBean.getObjectTree();
		
			}else{
				throw new Exception(ret.getMessage());
			}
	    	return nodeHelper;
		} finally {
			close();
		}
	}
	
	/**
	 * Load all node from database
	 * 
	 * @return List of node objects
	 *         contained in one ArrayList<NodeVO> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<NodeVO> loadNodes() throws EJBException, Exception{
	 
		try{
			ArrayList<NodeVO> lstNodes = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstNodes =dbServerBean.loadNodes();
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstNodes;
		} finally {
			close();
		}
	}
	
	/**
	 * Load all block from database
	 * 
	 * @return List of block objects contained in one ArrayList<BlockVO> object
	 *@throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<BlockVO> loadBlocks() throws EJBException, Exception{
	  	try {  
	  		ArrayList<BlockVO> lstBlocks = null;
	  		JResult ret = open();
	  		if(ret.isSucceeded()){
	  			lstBlocks =dbServerBean.loadBlocks();
	  		}else{
	  			throw new Exception(ret.getMessage());
	  		}
	  		return lstBlocks;
	  	} finally {
	  		close();
	  	}
	}
	
	/**
	 * Get Alarm info of block and packages child
	 * 
	 * @param blockID
	 *            Block's ID
	 * @return null if an error occurred or no block found, otherwise BlockVO object
	 */
	public BlockVO getBlockAlarmInfo(long blockID) throws EJBException, Exception{
		  try {
			  BlockVO bvo = null;
			  JResult ret = open();
			  if(ret.isSucceeded()){
				  bvo =dbServerBean.getBlockAlarmInfo(blockID);
			  }else{
				  throw new Exception(ret.getMessage());
			  }
			  return bvo;
		  } finally {
			  close();
		  }
	}
	
	/**
	 * Load all package from database
	 * 
	 * @return List of package objects contained in one ArrayList<PackageVO> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<PackageVO> loadPackages() throws EJBException, Exception{
	  try {
		  ArrayList<PackageVO> lstPackages = null;
		  JResult ret = open();
		  if(ret.isSucceeded()){
			lstPackages =dbServerBean.loadPackages();
		  }else{
			  throw new Exception(ret.getMessage());
		  }
		  return lstPackages;
	  } finally {
		  close();
	  }
	}
	
	/**
	 * Load all port from database
	 * 
	 * @return List of port objects contained in one ArrayList<PortVO> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<PortVO> loadPorts() throws EJBException, Exception{
		try {
			ArrayList<PortVO> lstPorts = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstPorts =dbServerBean.loadPorts();
			} else {
				throw new Exception(ret.getMessage());
			}
			return lstPorts;
		} finally {
			close();
		}
	}
	/**
	 * Get list of package-package connection (without port info) with a specified condition
	 *
	 * @return List of user objects contained in one ArrayList<PackageConnection> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */ 
	public ArrayList<PackageConnection> loadPackageConnection() throws EJBException, Exception{
		try {
			ArrayList<PackageConnection> lstPackageConn = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstPackageConn =dbServerBean.loadPackageConnection();
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstPackageConn;
		} finally {
			close();
		}
	}
	/**
	 * Load all type of package from database and contains into one the list
	 * object
	 * @return ArrayList<PackageTypeVO> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<PackageTypeVO> loadPackageTypes() throws EJBException, Exception{
		try {
			ArrayList<PackageTypeVO> lstPackageTypes = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstPackageTypes =dbServerBean.loadPackageTypes();
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstPackageTypes;
		} finally {
			close();
		}
	}
	
	/**
	 * Load package-port connection (package-package connection contains port info) 
	 * from database and contains into one the ArrayList<PPConnection> list object
	 *
	 * @return ArrayList<PPConnection> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<PPConnection> loadPPConnection() throws EJBException, Exception{
		try {
			ArrayList<PPConnection> lstPPConn = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstPPConn =dbServerBean.loadPPConnection();
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstPPConn;
		} finally {
			close();
		}
	}
	/**
	 * Load all user in database (root account is not involved) and contains into one the list object
	 * @return list of user objects contained in one ArrayList<UserVO> object
	 * @throws Exception        
	 *         	throws a exception if an error occurs.
	 */
	public ArrayList<UserVO> loadUsers() throws EJBException, Exception{
		try {
			ArrayList<UserVO> lstUsers = null;
			JResult ret = open();
			if(ret.isSucceeded()){
				lstUsers =dbServerBean.loadUsers();
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstUsers;
		} finally {
			close();
		}
	}
	/**
	 * Reset all parameters value for new get trap process
	 * @throws RemoteException
	 * @throws Exception
	 */ 
	public void resetGetTraps() throws EJBException, Exception{
		JResult ret = open();
		if(ret.isSucceeded()){
			dbServerBean.resetGetTraps();
	  	  	close();
		}else{
			throw new Exception(ret.getMessage());
		}
	  
	}
	
	/**
	 * Get trap history by filter records from database by combine 6 parameters together
	 * @param startTimeStamp
	 * @param endTimeStamp
	 * 					startTimeStamp/endTimeStamp is a long number, this number long can get by 
	 * 					convert DateTime type like "2009-01-01 12:30:59". Specify one or both is 0 
	 * 					if do not want to filter the record result according the time
	 * @param blockName
	 * 					Name of function block. Set null if want to ignore the block name condition
	 * @param alarmType
	 * 					Name of trap type. Set null if want to ignore the trap type condition
	 * @param orderIncrease
	 * 					Sort the result according order increase or decrease by time. Set true for order increase,
	 * 					otherwise false
	 * @return list TrapVO object contained in ArrayList<TrapVO> object
	 * @throws Exception if any error occurs
	 */	
	public ArrayList<TrapVO> loadTrapHistory(long startTimeStamp
		  					, long endTimeStamp, String blockName, String alarmType
		  					, boolean orderIncrease) throws EJBException, Exception{
		ArrayList<TrapVO> lstTraps = null;
		try{
			JResult ret = open();
			if(ret.isSucceeded()){
				lstTraps =dbServerBean.getTrapHistorys(startTimeStamp, endTimeStamp, blockName, alarmType, orderIncrease, 0);
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstTraps;
		} finally {
			close();
		}
		
	}
	
	/**
	 * Get trap history on trap view table 
	 * together

	 * @param blockIP
	 *            IP address of function block. Set null if want to ignore the block
	 *            name condition

	 * @return list TrapVO object contained in ArrayList<TrapVO> object
	 * @throws Exception
	 *             if any error occurs
	 */
	public ArrayList<TrapVO> getTrapOnView(String blockIP) throws EJBException, Exception{
		ArrayList<TrapVO> lstTraps = null;
		try{
			JResult ret = open();
			if(ret.isSucceeded()){
				lstTraps =dbServerBean.getTrapOnView(blockIP);
			}else{
				throw new Exception(ret.getMessage());
			}
			return lstTraps;
		} finally {
			close();
		}
	}
	
	
   /**
	* Reset all parameters value for new get user log process
	* @throws RemoteException
	* @throws Exception
	*/
	public void resetGetLogs() throws EJBException, Exception{
		JResult ret = open();
		if(ret.isSucceeded()){
			dbServerBean.resetGetUserLog();
			close();
		}else{
			throw new Exception(ret.getMessage());
		}
	  
	}

	/**
	 * Get user's log 
	 * @param orderIncrease
	 * 					Sort the result according order increase or decrease by time. Set true for order increase,
	 * 					otherwise false
	 * @return list OperationVO object contained in ArrayList<OperationVO> object
	 * @throws Exception if any error unknown occurred
	 */	
	public ArrayList<OperationVO> loadUserLog(boolean orderIncrease) 
  													throws EJBException,Exception {
		ArrayList<OperationVO> lstUserLogs = null;
		try{
			JResult ret = open();
			if (ret.isSucceeded()) {
				lstUserLogs = dbServerBean.getUserLogs(orderIncrease, 0);
			} else {
				throw new Exception(ret.getMessage());
			} 
			return lstUserLogs;
		} finally {
			close();
		}
		
	}
  
  
   /**
	* Login into server using user name and password
	* @param userName
	* @param password
	* @param userIP
	* 			Current not used, so set to null
	* @return JResult object. Check method isSucceeded() of this for true if successful,
	* 		 otherwise false
	* @throws RemoteException
	* @throws Exception
	*/
	public JResult login(String userName, String password, String userIP) throws EJBException, Exception{
		try{
			JResult ret = open();
			if(ret.isSucceeded()){
				ret =dbServerBean.login(userName,password);
				
			} else {
				throw new Exception(ret.getMessage());
			}
			return ret;
		} finally {
			close();
		}

	}
	
	/**
	 * Logout user
	 * @param userIP
	 * 				IP address of user
	 * @return JResult object. Check method isSucceeded() true if successful, otherwise false
	 * @throws EJBException
	 * @throws Exception
	 */
	public JResult logout(String userIP) throws EJBException, Exception{
	 try {
		JResult ret = open();
		if(ret.isSucceeded()){
			ret =dbServerBean.logout(userIP);
		} else {
			throw new Exception(ret.getMessage());
		}
		return ret;
	 } finally {
		 close();
	 }
	}
	/**
	 * Delete user from database who specified by user name
	 * @param userName
	 * @return JResult object. Check method isSucceeded() true if successful, otherwise false
	 * @throws RemoteException
	 * @throws Exception
	 */  
	public JResult deleteUser(String userName) throws EJBException, Exception{
		JResult ret = open();
		if(ret.isSucceeded()){
			ret =dbServerBean.deleteUser(userName);
	  	  	close();
		}else{
			throw new Exception(ret.getMessage());
		}
		return ret;
	}
  
	/**
	 * This method used only for client. Client will call this to notify to 
	 * user checker to keep alive timeout
	 */
	public void sendLivingSign(){
		try {
			Vector<UserVO> vtUserOnline = DBFunctionsManager.getListUserOnline();
			LogWriter.getDBLogger().info("User IP: " + dbServerBean.getUserIP() + "  sent time living sign.");
			for(int i = 0; i< vtUserOnline.size(); i++){
				UserVO _uvo = vtUserOnline.get(i);
				if(_uvo.getIPAddress().equalsIgnoreCase(dbServerBean.getUserIP())){
					//update time for user
					_uvo.setCountTimeAccess(0);
					DBFunctionsManager.join(_uvo);
					LogWriter.getDBLogger().info("Time living sign updated for " + _uvo.getName());
			  
				}
			}
		} catch (Exception e){}
	}
	
   /**
	* Load all alarm type from server
	* @return ArrayList<String>
	* @throws RemoteException
	*/	
	public ArrayList<String> loadAlarmType(){
		if(!DBFunctionsManager.isLoadedAlarmType()){
			if(!AlarmType.loadAlarmType()){
			  return null;
			}
			DBFunctionsManager.setLoadedAlarmType(true);
		}
		return AlarmType.getAlarmType();
	}
  }

⌨️ 快捷键说明

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