High-Level ConsiderationsOn the surface C# has many similarities to Java, and it would appear that a code-based port, where you take the C# code and translate it into Java, would be relatively straightforward, with only a few minor differences in semantics. It isn't. This is because in most cases, the code is written to use a specific class library. In the case of .NET, this library is defined by the .NET framework and any custom add-ons that are used. In the case of Java, this library is the Java SE, Java EE SDKs and any other custom add-ons used. While the language syntax is pretty similar between the two, the frameworks are going to be different in many ways, making a straight translation difficult. As such, it is more accurate to think about translating an application from one that runs on the .NET Framework to one that runs on a Java SE/Java EE environment. When thinking about the translation in this way, it becomes easier (and more accurate) to isolate the potential issues that are faced in migration. A number of these issues are
Strategies for Porting Enterprise ApplicationsThere are many strategies and patterns that could be followed for porting Enterprise Applications, but the overarching desire behind all of them is to do it at minimum cost and with minimal disruption to the systems. One very useful strategy to enable this is to migrate in small steps and to use Web services at every application boundary. As Web services are based on known standards at the interface, namely Simple Object Access Protocol (SOAP), it doesn't matter how they are physically implemented. A Web service is in fact an abstract entity, accessed via HTTP using SOAP documents. If .NET applications are not currently implemented using Web services, a good first step would be to implement them as Web services. One can then take the interface to these Web services, which is defined using a standard language (Web Services Definition Language or WSDL), and create new Java-based Web services from this interface description. The systems that interface to this won't know the difference that providing the WSDL for the Java Web service is the same as that for the .NET. This gives a step-by-step migration which will help minimize disruption to operational systems. The example that will be used for porting is based on the Web Services Interoperability Organization (WS-I), Supply Chain Management application [WSI-1], used throughout this book. The Web services-based distributed Supply Chain Management application manages the request for a product through the consumer making an online purchase, a number of warehouses that may stock the required item, and the manufacturers of the cataloged items. It is a good example for an application that shows a number of different organizations with potentially different IT infrastructures operating together. This chapter looks at the relationship between the Retailer that sells the goods and its warehouse and the services that implement this relationship. Figure 16-1 provides a high-level diagram of .NET Retailer system services that will be ported to Java EE. Figure 16-1. .NET Retailer Service consuming .NET Warehouse service
The first thing to look at is how these services are built in C# and running on the .NET platform and then migrating them to Java EE in two ways: using Mainsoft's Visual MainWin and by manually rewriting the code from C# to Java. This provides a nice hands-on use case for a migration, as initially one ports the Warehouse service and leaves the Retailer one as-isyet the application still works across the technology boundaries with a .NET-based Retailer service and a Java-based Warehouse service. This is shown in Figure 16-2. Figure 16-2. .NET Retailer service consuming Java EE Warehouse service
Finally, the Retailer is ported in the same manner. This also shows an additional benefit of Service Oriented Architecture (SOA) and how it can reduce the costs and risks of incrementally porting projects due to their loosely coupled nature. The final set of components are shown in Figure 16-3. Figure 16-3. Java EE Retailer service consuming Java EE Warehouse ShipGoods service
This isn't the only strategy of course; there are many ways to achieve migration with minimal fuss, but this is a very useful one and is the basis of many of the examples in this chapter. |