📄 r_stockrw.java
字号:
package Remote;
import java.rmi.*;
import Catalogue.*;
import DBAccess.*;
import Middle.*;
import javax.swing.ImageIcon;
// There can only be 1 resultset opened per statement
// so no simultaneous use of the statement object
// hence the synchronized methods
/**
* Implements Read/Write access to the stock list,
* the stock list is held in a relational DataBase.
* @author Michael Alexander Smith
* @version 2.0
*/
public class R_StockRW
extends java.rmi.server.UnicastRemoteObject
implements RemoteStockRW_I
{
private static final long serialVersionUID = 1;
private StockRW aStockRW = null;
private StockR aStockR = null;
public R_StockRW(String url)
throws RemoteException, StockException
{
aStockRW = new StockRW();
aStockR = new StockR();
}
public synchronized boolean exists( String number )
throws StockException
{
return aStockR.exists( number );
}
/**
* Returns details about the product in the stock list
* @return StockNumber, Description, Price, Quantity
*/
public synchronized Product getDetails( String number )
throws StockException
{
return aStockR.getDetails( number );
}
/**
* Returns an image of the product in the stock list
* @return image
*/
public synchronized ImageIcon getImage( String number )
throws StockException
{
return aStockR.getImage( number );
}
/**
* Buys stock and hence decrements no in stock list
* @return StockNumber, Description, Price, Quantity
*/
// Need to Fix
// What happens if can not commit data
//
public synchronized boolean buyStock( String number, int amount )
throws StockException
{
return aStockRW.buyStock( number, amount );
}
/**
* Adds (Restocks) stock to the product list
*/
public synchronized void addStock( String number, int amount )
throws StockException
{
aStockRW.addStock( number, amount );
}
/**
* Modifies Stock details for a given product number.
* Information modified: Description, Price
*/
public synchronized void modifyStock( Product detail )
throws StockException
{
aStockRW.modifyStock( detail );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -