Reputation: 151
I have a class called ServerSide in which another class resides called Cserver. The following code fragment should explain what I am talking about:
public static void main (String [] args) throws Exception
{
System.out.println("The server is running.");
int clientnumber = 1;
ServerSocket server = new ServerSocket(9090);
try
{
while (true)
{
new cserver(server.accept(), clientnumber++).start();
}
}finally
{
server.close();
}
}
private static class cserver extends Thread
{
private Socket socket;
private int clientnumber;
private ConnectionHandler c_handler;
private Protocol protocol;
public cserver(Socket socket, int clientnumber)
{
this.socket = socket;
this.clientnumber = clientnumber;
log("New connection with Client: " + clientnumber + " at " + socket);
}
I want to make a class diagram in UML which shows the relationship between the two classes, as I am unsure as how this can be drawn in UML. Will it be an association? Thanks
Upvotes: 15
Views: 72217
Reputation: 979
The meaning of this relationship is: "cserver class is a Thread class, but Thread class is not a cserver class."
I recommend you to use CServer
as class name, check these Java naming conventions: http://en.wikipedia.org/wiki/Naming_convention_(programming)#Java
Upvotes: 6
Reputation: 43117
This would be the diagram, it's an inheritance relation (IS-A):
Upvotes: 27
Reputation: 716
This is inheritance: http://www.teach-ict.com/as_as_computing/ocr/H447/F453/3_3_6/uml/miniweb/pg6.htm
In Java extends explicitly defines the IS-A relationship.
Upvotes: 3