Figure 22-13 Share project using CVS page 1 Select CVS as the repository type.. Figure 22-15 Share project using CVS page 3 Note: The third option, File System Example, allows you to get
Trang 1Creating and sharing the project (step 1 - stade1)
Application Developer offers a perspective specifically designed for viewing the contents of CVS servers: the CVS perspective For additional information concerning this perspective, please refer to the “CVS Repository Exploring perspective” on page 73
Adding a CVS repository
Open the CVS Repository Exploring perspective We use the CVS Repositories
view to add the repository location created in “Creating a CVS repository on CVSNT” on page 703
Select New -> Repository Location from the context menu to open the Add CVS Repository dialog (Figure 22-10)
Figure 22-10 Adding a CVS repository Type localhost (or the server name or IP address of your CVS server) in the
Host field In the Repository path field, type /RedBank Recall that /RedBank was the path specified when you created the repository, including the leading slash
Substitute for you own user ID and password
Trang 2Type the appropriate authentication data in the User and Password fields for the first developer Connect with the server using the pserver protocol and the default port, and select Validate Connection on Finish
Click Finish, and the CVS Repositories view now contains the new repository location (Figure 22-11)
Figure 22-11 CVS Repositories view
Expanding a location in CVS Repository view reveals branches and versions A special branch, called HEAD, is shown detached because of its importance It is the main integration branch, holding the project’s current development state You can use the CVS Repositories view to checkout repository resources as projects on the Workbench You can also configure branches and versions, view resource histories, and compare resource versions and revisions
We must first create a project and share it before making full use of the
repository
Create a project
Switch to the J2EE perspective and create a new EJB project called
ItsoProGuideCVS by selecting File -> New -> EJB Project
In the wizard’s first page, select Create 2.0 EJB Project and click Next to proceed
to the second page (Figure 22-12)
Important: With pserver, passwords are stored on the client side in a trivial
encoding and transmitted in the same encoding The encoding is done only to prevent inadvertent password compromises, and will not prevent an attacker from obtaining the password The other supported protocol, ssh, does not have this problem, but has to be manually set up
Trang 3Figure 22-12 Create EJB project Click Finish to create the project The new project now appears in the J2EE Navigator view Share the project by selecting Team -> Share Project from its context menu The Share Project wizard opens (Figure 22-13)
Figure 22-13 Share project using CVS (page 1) Select CVS as the repository type Sharing a project using Rational ClearCase is explained in “Adding a project to ClearCase source control” on page 762
Trang 4Click Next and select the existing repository location that you defined earlier You could also create a new repository location from here, if it was not already defined (Figure 22-14)
Figure 22-14 Share project using CVS (page 2)
Click Next to proceed to the next page of the wizard Here you could specify a different name for the CVS module than the project name, but we do not want to
do that We leave the default, as shown in Figure 22-15, and click Finish to complete the wizard
Figure 22-15 Share project using CVS (page 3)
Note: The third option, File System Example, allows you to get and put files
from and to a shared network directory without any kind of locking or version control
Trang 5After sharing the project in CVS, Application Developer opens the Synchronize
view (Figure 22-16)
Figure 22-16 Synchronizing project with repository before adding to version control The question marks indicate that the resources do not exist in the repository; only the project is in the repository for now
Select the project folder (ItsoProGuideCVS) and select Add to Version Control
from the context menu The Synchronize view is updated (Figure 22-17)
Figure 22-17 Synchronizing project with repository after adding to version control Now select Commit from the ItsoProGuideCVS project’s context menu to commit the changes to the repository
You are prompted to enter a commit comment It is important to describe the changes to the files that are committed to the repository In our case, we are just adding the empty project, so we enter Initial Project Load as the description (Figure 22-18)
Trang 6Figure 22-18 Comment for files committed to repository Click OK to commit the changes to the repository The project is now shared
Adding a shared project to the workspace (step 2 - stade2)
The point of using CVS is to allow multiple developers to work in a team on the same project We have created the project in one developer’s workspace, shared
it using CVS, and now wish to add the same project to a second developer’s workspace
First of all, the second developer must add the CVS repository location to the workspace using the CVS Repositories view in the CVS perspective, as described in “Adding a CVS repository” on page 714
The difference is now that the HEAD branch in the repository, if expanded, contains the ItsoProGuideCVS module, as shown in Figure 22-19
Figure 22-19 CVS Repository with ItsoProGuideCVS project Select the ItsoProGuideCVS module and Check Out As Project (context) The current project in the HEAD branch is added to the workspace
Trang 7Developing the Customer bean
Now that both developers have exactly the same synchronized HEAD branch of the ItsoProGuideCVS project on their workspaces, it is time for the second developer to create the first EJB: Customer
Define the Customer bean as described in “Define the Customer bean” on page 389, but use the ItsoProGuideCVS project
When you are done, the generated files are shown in the J2EE Navigator view (Figure 22-20)
Figure 22-20 J2EE Navigator view after creating the Customer entity bean
Synchronizing with the repository
To update the repository with these changes, select the ItsoProGuideCVS project and select Team -> Synchronize with Repository from its context menu The project is compared with the repository, and the differences are displayed in the
Synchronize view (Figure 22-21)
Tip: The “greater than” sign in front of a resource name means that the
particular resource is not synchronized with the repository You can always use this visual cue to determine when a project requires synchronization
Trang 8Figure 22-21 Synchronizing ItsoProGuideCVS after creating the Customer bean
This view allows you to update resources in the Workbench with newer content from the repository, commit resources from the Workbench to the repository, and resolve conflicts that may occur in the process The question mark icons indicate that the files do not exist in the repository
Add these new resources to version control by selecting ItsoProGuideCVS in this view and then Add to Version Control from its context menu Figure 22-22 shows the updated Synchronize view
Figure 22-22 Synchronize view with files added to version control
new folders/files
Trang 9To actually add the files to version control, you must commit the changes Select the ItsoProGuideCVS project on the Synchronize view and select Commit from its context menu You are prompted to enter a commit comment (Figure 22-23)
Figure 22-23 Customer commit comment Click OK to add the comment and commit the files to the repository
Synchronizing with repository (step 3 - stade1)
The first developer now wants to start developing his or her own beans Before doing that, though, it is recommended that the project be synchronized with the repository, to guarantee that it contains the most up-to-date files This make future merging of changes easier
In the J2EE Navigator view, select the ItsoProGuideCVS project and Team -> Synchronize with Repository (context) The Synchronize view opens
(Figure 22-24)
Figure 22-24 Synchronizing workspace with repository
new
new
modified
Trang 10Because the first developer has not created or changed anything since the last synchronization with the repository, there are absolutely no conflicts to resolve; only the deployment descriptor must be replaced and five new files must be added to the workspace
Select the ItsoProGuideCVS project in the Synchronize view and select Update from Repository (context) Figure 22-25 shows the updated J2EE Navigator view
Figure 22-25 J2EE Navigator on the first developer’s machine after synchronization
Parallel development (step 4 - stade1 and stade2)
Up to this point, we have created the repository and the EJB project, added the project to the repository, developed an entity bean, and synchronized both developers’ workspaces with these changes None of these steps were carried out in parallel by the two developers
Now it is time to do some parallel development, just like you would do in a real life scenario The first developer create the Account bean and the second developer creates the TransRecord bean The synchronization of workspaces will happen only after both are done, so that conflicts show up and can be resolved
First developer creates the Account bean
Create the Account entity bean with two CMP fields and no extra logic:
id—String, key attribute
balance—int, promote to local Important: Do not commit to the repository yet We want the second
developer to create the TransRecord bean so that conflicts arise