!--a11y-->
Scenario 2: Step 1 – Create and Locally Build
a Java DC 
In
this step, developer 1 creates a simple
development
component (DC) of
type Java
and exposes some classes in a
public part (which
you could call a DC interface).
...
You have started the SAP NetWeaver Developer Studio.
1. Open the Development Configurationperspective.
2.
To log
on to the DTR, choose
in the
toolbar or log on in the context menu of the Active DCs view.
Enter USER1 and the corresponding password.
3. In the Development Configuration perspective, switch to the Active DCs view.
4. Open the CONFIG1 folder.

Besides the software components (SCs) example.org_technology and example.org_application, which you are meant to develop, you see these three entries:
· sap.com_SAP_BUILDT
· sap.com_SAP_JTECHS
· sap.com_SAP-JEE
You can use them but not change them.
You are in the Development Configuration perspective.
...
1. Select the entry example.org_technology. In the context menu, choose Create new DC.
A wizard Development Component Project appears.
2. In the wizard, enter the following:
a. Vendor: example.org
b. Name: technology/tax/calculator
c. Caption: Tax Calculator
d. Type: Java.
3. Choose Next.
A dialog window DTR Activity appears.
4. To create a new activity, choose New Activity.

This activity is used to record the creation of the component in the DTR.
5. Enter New Java Component as display name of the new activity and choose OK.
The dialog window DTR Activity appears. Your new activity is selected.
6. Choose Next.
The dialog window New Java Project appears.
7. Accept the proposed settings by choosing Finish.
The wizard now creates the DC. The Java perspective is opened automatically and you see a new project for your component in the Package Explorer view.
You are in the Java perspective.
...
1. Choose the view Package Explorer.
2. Open the project node of your component and select the src/packages folder.
3. From the context menu, choose New ® Package.
4. Enter org.example.tax as name of the new Java package and choose Finish.
...
1. Select the package org.example.tax and choose New ® Interface from the context menu.
2. Enter ITaxCalculator as name and choose Finish.
The dialog window Add files to DTR appears.
3. When asked to add the new file to the Design Time Repository, confirm this by choosing OK.
4. Select your activity New Java Component and again choose OK.

For certain development steps, you can specify an activity as the default activity. All your changes are automatically added to this activity. To do this, in the Open Activities view choose Use as Default from the context menu of an activity. To deactivate this option, in the same view in the context menu of the workspace, choose Always Explicitly Select Activity. If, for example, you want to create a new DC, you should choose this option or select a new default activity, because activities are – among others – used to group related file versions.
The Java editor for ITaxCalculator appears automatically.
5. Insert the following code:
package org.example.tax;
public interface ITaxCalculator {
double calculateTax(double income);
}
6. Save your entries.
You are in the Jave perspective in the Package Explorer view.
...
1. Select the package org.example.tax and choose New ® Class from the context menu.
2. Enter TaxCalculator as name and choose Finish.
A dialog window appears.
3. When asked to add the new file to the DTR repository, confirm this by choosing OK.
4. Select activity New Java Component, if necessary, and again choose OK.

If you specified this activity as the default activity, the query does not appear.
The Java editor for TaxCalculator appears automatically.
5. Insert the following code:
package org.example.tax;
public class TaxCalculator implements
ITaxCalculator{
private double
rate = 0.5;
public double
calculateTax(double income) {
return
income*rate;
}
}
6. Save your entries.
...
1. Select the package org.example.tax and choose New ® Class from the context menu.
2. Enter TaxFactory as name and choose Finish.
A dialog window appears.
3. When asked to add the new file to the DTR repository, confirm this by choosing OK.
4. Select activity New Java Component, if necessary, and again choose OK.
The Java editor for TaxFactory appears automatically.
5. Insert the following code:
package org.example.tax;
public class TaxFactory {
public static ITaxCalculator createInstance(){
return new TaxCalculator();
}
}
6. Save your entries.
You are in the Java perspective.
...
1. Switch to the Java DC Explorer view.
2. In the context menu of your DC, choose Development Component ® Build...
The dialog window Build Development Components appears.
3. Select your project node and confirm with OK.

The component is compiled, but no archives are created since the component up to now has no public parts.
Add a public part to the component to publish ITaxCalculator and TaxFactory. You are in the Java perspective.
...
1. Go to the Java DC Explorer view.
2. To add a public part, open the node DC MetaData.
3. Select the node Public Parts.
4. From the context menu, choose New Public Part...
The dialog window Add Public Part appears.
5. In the dialog, enter api as name of the new public part.
6. Select the radio button Provides an API for developing/compiling other DCs.

This creates a public part other components can
compile against. For more information on the purposes of public parts, see
Purposes of
Public Parts.
7. Enter API of the Tax Calculator as caption.
8. To confirm your changes, choose Finish.
A dialog window appears.
9. When asked to add the new file to the DTR repository, confirm this by choosing OK.
10. Select activity New Java Component, if necessary, and again choose OK.
...
1. Open the Public Parts node in the Java DC Explorerview.
You see a new entry named api.
2. Select api ® Entities and choose Edit Entities… from the context menu.
A dialog window Input Help: Entities appears.
3. Select Java Class in the Select Entity Type tree and mark the checkboxes of the following entries in the hierarchical display:
a. ITaxCalculator
b. TaxFactory.
4. In the section Add Entity to Public Part, select the entry as Classand confirm with Finish.
This adds ITaxCalculator and TaxFactory to the public part.
You are in the Java perspective in the Java DC Explorer view.
...
1. In the context menu of your DC, choose Development Component ® Build...
The dialog window Build Development Components appears.
2. Select your project node (if necessary) and confirm with OK.
An archive for the selected DC is created.

Check this: In the Package Explorer view, follow the path: gen ® default ® public ® api ® lib ® java: The archive is named example.org~technology~tax~calculator~api.jar.
You are in the Java perspective in the Java DC Explorer view.
...
1. To add a public part, open the node DC MetaData and select Public Parts.
From the context menu, choose New Public Part.A dialog window appears.
2. In the New Public Part dialog, enter tax as the name of the new public part.
3. Select the radio button Can be packaged into other build results (e.g.SDAs).

This public part is used to assemble a runtime archive containing the full set of classes. Furthermore, this public part later will be used to wrap this library with a deployable J2EE library.
To display and change the
purpose of the
public part, use the Properties view.
4. Enter Tax Calculator Library as caption.
5. To confirm your changes, choose Finish.
A dialog window appears.
6. When asked to add the new file to the DTR repository, confirm this by choosing OK.
7. If you do not use a default activity, select the New Java Component activity and again choose OK.

Open the Public Parts node in the Java DC Explorerview. You now see two public parts, api and tax.
...
1. Select the Entities node of tax and in the context menu, choose Edit Entities.
A wizard appears.
2. In the Select Entity Type list, select the entry Java Package Tree.
3. In the Select Entities tree, select the entry org.
4. In the section Add Entity to Public Part, select the entry as Class.
5. To confirm your entries, choose Finish.

This will add the Package Tree to the public part. You can now see the entries under the Entities node.
You are in the Java perspective.
...
1. Choose the Java DC Explorer view.
2. In the context menu, choose Development Component ® Build...
The dialog window Build Development Components appears.
3. Select your project node (if necessary) and confirm with OK.
Now the component build creates two archives:
¡ example.org~technology~tax~calculator~api.jar contains the classes against which other components can compile.
¡ example.org~technology~tax~calculator~tax.jar contains all classes, but is not usable for component builds. Therefore, the class TaxCalculator is private to the component.

You can find them in the Java perspective in the Package Explorer view under the path: Project node ® gen ® default ® public ®
· api ® lib ® java ® api.jar
· tax ®lib ® java ® tax.jar
...
1. Switch to the Development Configuration perspective.
2. In the Open Activities view, select your activity New Java Component.

You can add the Open Activities view to other perspectives in order to avoid switching the perspective.
3. Choose Checkin from the context menu.
A dialog window appears.
4. Enter a description of your changes if you like and choose OK.
All changes are stored on the DTR server.
