Development components (DCs) can use other DCs. For example, if you want DC1 to use the functions of another DC - DC2, then the development object that you need has to be declared as a public part of the DC. Since the development object 2 of DC2 is declared as a public part, it is now visible to the DC1. Using a usage dependency, the DC1 can now use development object 2 of DC2.
You are logged on to the development infrastructure. You are not performing local development, but use a software component (SC) from the development configuration for your development.
Adding development objects to a new DC project
Depending on the type of your DC, add some new application-specific objects to the DC project you created. For example, create Java classes in the Java DC or a session bean in an EJB Project or a Web Dynpro component in a Web Dynpro project.
To keep this test case simple, add a new Java class Test to the DC (DC2) and implement a simple method getName() that is intended to be invoked by another Java class Accessor from another DC (DC1). To create a new Java class, open the Package Explorer view and select the project root for the DC2. Choose New → Class… Implement the following code:
public class Test { public static String getName() { return "My company name!"; } } |
Providing Functions to Other DCs
To create a public part for a DC, proceed as follows:
In the Development Infrastructure perspective, choose the DC you want to modify and from the Component Properties view, open the Public Parts tab.
Choose Add… and specify the properties of the public part to be created:
Public Part Properties
Name |
A name for the public part. This name must be unique within DC. |
Purpose |
Specify the application purpose. You can choose between the following three values:
|
Caption |
Name by which the public part will be identified in visual tools. |
Description |
Explains the meaning of the public part. |
Choose Finish .
All the objects that are included in the public part have been made visible to the outside for external use. On the other hand, all the other parts of the DC that do not belong to any public part are - accordingly - not visible and therefore protected from access.
Assigning a DTR activity
Select the resource you want to add to an activity.
From the context menu, choose
.In the dialog that appears, choose New... to create a new activity (or choose an already existing activity).
Specify a display name and description of the new activity and choose OK .
The new activity is created and you can view it under the Open Activities view.
Triggering a DC build in Component Build Service (CBS)
You need to execute the DC build to be able to reference the development objects (such as a Java class) that have been propagated to the public part by a development object in another DC.
To trigger the DC build, select the project root for the DC and choose Build from the context menu.
Using Functions from Other DCs
Create a second DC (client DC) with a project type of your choice. Assign a new activity.
Create some development objects to complete the DC project.
To keep this test case simple, add a new Java class Accessor to the (client) DC you have just created and implement a simple method printTestName() that will be used to invoke the getName() method of the Test class that is part of the other (provider) DC.
public class Accessor { public void printTestName() { System.out.println(Test.getName()); } } |
To create a usage dependency for the new DC, choose the DC and open the Dependencies tab.
Choose Add , and then choose the DC to be referenced. Choose Next .
Specify the time when the dependency you are going to define is to be valid (such as Build Time) and choose Finish .
A usage dependency for a DC to use a public part of another DC is created. The client DC can access all the development objects from the public part of the first DC and the development objects that were added to the public part can be resolved in the client DC.