AppletInterface
Class StockTradingApplication

java.lang.Object
  extended byjava.lang.Thread
      extended byamber.server.application.ApplicationHandler
          extended byAppletInterface.StockTradingApplication
All Implemented Interfaces:
amber.server.application.ApplicationInterface, java.lang.Runnable, java.io.Serializable

public class StockTradingApplication
extends amber.server.application.ApplicationHandler

Author:
student This class is being used as a host supporting all the frames. This class manages communication with Amber server.
See Also:
Serialized Form

Field Summary
private  UserAddress_Data address
           
private  LoginFrame frmLogin
          Declare any panels or frames this application uses.
private  Stock_Data[] stocks
           
private  User_Data user
           
 
Fields inherited from class amber.server.application.ApplicationHandler
closeableObjects, connection, eventHandler, input, loggingFile, output, packetHandler, pageId, pageSubId, parentServer, receivedPackets, receiver, sender, sessionInfo, waitForClientShutDown, waitForPacket
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StockTradingApplication()
          This is the constructor for StockTradingApplication.java
StockTradingApplication(int appIdentifier)
          The initialising constructor.
StockTradingApplication(int appIdentifier, java.net.Socket newConnection)
          The initialising constructor.
 
Method Summary
protected  void defineComponents()
          Do initialisation that needs to be done within the constructor, eg add any panels/frames this application uses.
 UserAddress_Data getAddress()
          This method is being used for getting the address details.
 amber.type.server.XYConstraints getCentredWindowXYConstraints(int windowWidth, int windowHeight)
          This method is being used for getting appropriate x, and y co- ordinates to support the specified width and height.
 Stock_Data[] getStocks()
          Method: getStocks This method is being used for getting all the stocks.
 User_Data getUser()
          This method is being used for getting user details.
 void setAddress(UserAddress_Data a)
          This method is being used for setting the address data.
 void setUp()
          This function is called when the program first starts.
 void setUser(User_Data u)
          This method is being used for setting user details.
 void start(java.net.Socket newConnection)
          This function initiates the functioning of the ApplicationHandler.
 
Methods inherited from class amber.server.application.ApplicationHandler
activateChildren, add, addCloseable, addComponent, addComponent, addInPostPacketListener, addInPrePacketListener, addOutPostPacketListener, addOutPrePacketListener, addReceivedPacket, computeMaximumDimensions, directPacket, encodeComponentState, fireInPostPacketPerformed, fireInPrePacketPerformed, fireOutPostPacketPerformed, fireOutPrePacketPerformed, forwardEventPacket, getAllCloseable, getClientScreenSize, getComponents, getConnection, getLog, getModalObject, getPageId, getPageSubId, getParentServer, getRemoteProperties, getSessionId, getValidId, isAlreadyCreated, isConnected, isMyPageId, isMyPageId, isSpecialPacket, logComponentStructure, processApplicationPacket, remove, removeCloseable, removeInPostPacketListener, removeInPrePacketListener, removeOutPostPacketListener, removeOutPrePacketListener, restart, run, sendPacket, sendReconnectionState, sendSessionInitialisationState, setClientScreenSize, setComponents, setConnectedState, setInitialValidId, setLog, setModalObject, setPageId, setPageSubId, setParentServer, setRemoteProperties, setSize, setUpComponent, setUpComponent, shutDown, shutDownClient, shutDownClient, start, terminateThreads
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

address

private UserAddress_Data address

frmLogin

private LoginFrame frmLogin
Declare any panels or frames this application uses. Note that each panel/frame corresponds to one APPLET tag in the HTML. Also note that the panel/frame ID must match the ID parameter in the html.


stocks

private Stock_Data[] stocks

user

private User_Data user
Constructor Detail

StockTradingApplication

public StockTradingApplication()
                        throws java.io.IOException
This is the constructor for StockTradingApplication.java


StockTradingApplication

public StockTradingApplication(int appIdentifier)
                        throws java.io.IOException
The initialising constructor.

Parameters:
appIdentifier - An int uniquely identifying this instance of application.

StockTradingApplication

public StockTradingApplication(int appIdentifier,
                               java.net.Socket newConnection)
                        throws java.io.IOException
The initialising constructor.

Parameters:
appIdentifier - An int uniquely identifying this instance of application.
newConnection - The Socket which is connected to the page in operation.
Method Detail

defineComponents

protected void defineComponents()
Do initialisation that needs to be done within the constructor, eg add any panels/frames this application uses. Use "add" to add the component into the application messaging loop.


getAddress

public UserAddress_Data getAddress()
This method is being used for getting the address details.

Returns:
UserAddress_Data Address details.

getCentredWindowXYConstraints

public amber.type.server.XYConstraints getCentredWindowXYConstraints(int windowWidth,
                                                                     int windowHeight)
This method is being used for getting appropriate x, and y co- ordinates to support the specified width and height.

Parameters:
windowWidth - Width of the frame.
windowHeight - Height of the frame.
Returns:
XYConstraints The dimensions of the frame.

getStocks

public Stock_Data[] getStocks()
Method: getStocks This method is being used for getting all the stocks.

Returns:
Stock_Data[] The retrieved stocks.

getUser

public User_Data getUser()
This method is being used for getting user details.

Returns:
User_Data The user details.

setAddress

public void setAddress(UserAddress_Data a)
This method is being used for setting the address data.

Parameters:
a - The address details.
Returns:
void

setUp

public void setUp()
This function is called when the program first starts. Insert into here any initial set up code you may require.


setUser

public void setUser(User_Data u)
This method is being used for setting user details.

Parameters:
u - The user details.
Returns:
void

start

public void start(java.net.Socket newConnection)
           throws java.lang.IllegalThreadStateException
This function initiates the functioning of the ApplicationHandler. This function is required as the application handler will not immediately start operation until it is handed the socket by the main handling system.

Parameters:
newConnection - The Socket which is connected to the page in operation. If null uses the connection already set.
Throws:
java.lang.IllegalThreadStateException - containing any problems.