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
In domain modeling class diagrams, an extends relationship (also called an inheritance or an is-a relationship) implies that a specialized (child) class is based on a general (parent) class. In domain modeling class diagrams, extends relationships apply only to container-managed persistence (CMP) entity beans.
In domain modeling class diagrams, an implements relationship represents a class that implements the operations in a Java™ interface. As the following figure illustrates, an implements relationship is displayed as a dashed line with an unfilled arrowhead.
Inheritance is shown in a class diagram by using a solid line with a closed, hollow arrow. Bidirectional association: The default relationship between two classes. Both classes are aware of each other and their relationship with the other. This association is represented by a straight line between two classes.
In UML modeling, you can use an extend relationship to specify that one use case (extension) extends the behavior of another use case (base). This type of relationship reveals details about a system or application that are typically hidden in a use case.
This would be the diagram, it's an inheritance relation (IS-A):
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With