Entering content frame

Procedure documentation Scenario 3: Step 1 – Create and Locally Build a Java DC Locate the document in its SAP Library structure

In this step, developer 1 creates a simple Structure linkdevelopment component (DC) of Structure linktype Java and exposes some classes in a Structure linkpublic part (which you could call a DC interface).

...

Prerequisites

You have started the SAP NetWeaver Developer Studio.

Importing Development Configurations from the SLD

Development configurations provide you with a development environment specifically for your software component (SC) in the current development state. For this reason, every development tasks begins with the selection of the development configuration.

Development configurations are created in the Change Management Service(CMS), stored in the System Landscape Directory (SLD) and imported from there into the SAP NetWeaver Developer Studio.

...

       1.      To open the Development Configurations perspective, choose Window ® Open Perspective ® Other... and select from the list of perspectives the entry Development Configurations.

       2.      To have access to the development configurations in the SLD, set the Development Configuration Pool in the SAP NetWeaver Developer Studio:

                            a.      In the menu chose Window  ® Preferences.

A dialog window appears.

                            b.      Open Java Development Infrastructure ® Development Configuration Pool.

                            c.      Under URL, enter the URL of the server on which the SLD is installed: http:<host>:<port>

                            d.      Confirm with OK.

       3.      To import a development configuration, open the context menu in the Local View and choose Import Configuration... 

       4.      Select the remote option.

A dialog window for logging on to the SAP NetWeaver Java Development Infrastructure appears.

       5.      Enter USER1 and the corresponding password.

The development configuration import wizard appears.

Note

In this window, you can set the storage location (the root folder) for the files created in this development configuration. To be able to change this setting, you must first remove all development configurations.

A list of the development components available in the SLD appears.

       6.      Select the required development configuration Appl_dev and confirm.

Note

The extension _dev stands for the development status of the SC. The Appl_cons development configuration is also created. After development, you can maintain the consolidation state in this development configuration.

The window Development Configuration Import appears.

       7.      Choose Next.

The Build Variants dialog window appears.

       8.      Choose Finish.

The system reads the development configuration settings and sets up your development environment.The views Active DCs,Inactive DCs, and Local DCs now contain a new entry with the name of the imported development configuration.

       9.      As the second development configuration, import Techno_dev

Check the Imported Development Configurations

...

       1.      In the perspective Development Configuration, switch to the Inactive DCs view.

       2.      Open the Appl_dev folder.

You can see only the software components which you will develop.

Note

In the scenarios 2+ and 3, the Component Build Service (CBS) is used. This is coupled with an activation concept: DCs can be created only in the Inactive workspace and are activated in the CBS only by a successful build. This makes them available automatically in the Active workspace, where they can be used for the build of other DCs.

       3.      Switch to the Active DCs view.

       4.      Open the Appl_dev folder.

Note

Next to the software components you want to develop, you see three entries:

·         sap.com_SAP_BUILDT

·         sap.com_SAP_JTECHS

·         sap.com_SAP-JEE

These SCs are provided and can be used but not changed.

       5.      Repeat the steps for Techno_dev.

Create a New Development Component (DC) and an Activity

You are in the Development Configuration perspective.

...

       1.      Open the node of your development configuration Techno_dev.

       2.      Select the entry example.org_technology.In the context menu, choose Create new DC.

A wizard Development Component Project appears.

       3.      In the wizard, enter the following:

                            a.      Vendor: example.org

                            b.      Name: technology/tax/calculator

                            c.      Caption: Tax Calculator

                            d.      Type: Java.

       4.      Choose Next.

A dialog window DTR Activity appears.

       5.      To create a new activity, choose New Activity.

Note

This activity is used to record the creation of the component in the DTR.

       6.      Enter New Java Component as display name of the new activity and choose OK.

The dialog window DTR Activity appears again. Your new activity is selected.

       7.      Choose Next.

The dialog window New Java Project appears.

       8.      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.

Add a Package to Your DC

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.

Add an Interface to Your DC

...

       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.

Note

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.

Add Classes to Your DC

You are in the Jave perspective in the Package Explorer view.

Add Class TaxCalculator

...

       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.

Note

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.

Add Class TaxFactory

...

       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.

Build Your DC Locally

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.

Note

The component is compiled, but no archives are created since the component up to now has no public parts.

Add Public Parts to Your DC

Public Part api

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 your DC node.

       3.      Open the DC MetaData node.

       4.      Select the node Public Parts.

       5.      From the context menu, choose New Public Part...

The dialog window Add Public Part appears.

       6.      In the dialog, enter api as name of the new public part.

       7.      Select the radio button Provides an API for developing/compiling other DCs.

Note

This creates a public part other components can compile against. For more information on the purposes of public parts, see Structure linkPurposes of Public Parts.

       8.      Enter API of the Tax Calculator as caption.

       9.      To confirm your changes, choose Finish.

A dialog window appears.

   10.      When asked to add the new file to the DTR repository, confirm this by choosing OK.

   11.      Select activity New Java Component, if necessary, and again choose OK.

Add Public Part Entities to Public Part api

...

       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.

Build Your DC Locally

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.

Note

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.

Public Part tax

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.

       2.      From the context menu, choose New Public Part.

A dialog window appears.

       3.      In the New Public Part dialog, enter tax as the name of the new public part.

       4.      Select the radio button Can be packaged into other build results (e.g.SDAs).

Note

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 Structure linkpurpose of the public part, use the Properties view.

       5.      Enter Tax Calculator Library as caption.

       6.      To confirm your changes, choose Finish.

A dialog window appears.

       7.      When asked to add the new file to the DTR repository, confirm this by choosing OK.

       8.      If you do not use a default activity, select the New Java Component activity and again choose OK.

Note

Open the Public Parts node in the Java DC Explorerview. You now see two public parts, api and tax.

Add Public Part Entities to Public Part 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.

Note

This will add the Package Tree to the public part. You can now see the entries under the Entities node.

Build Your DC Locally

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.

Note

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

Check In the Activity

...

       1.      Switch to the Development Configuration perspective.

       2.      In the Open Activities view, open the node of the development configuration and of the workspace.

You see your open activities.

       3.      Select activity New Java Component.

Note

You can add the Open Activities view to other perspectives in order to avoid switching the perspective.

       4.      Choose Checkin from the context menu.

A dialog window appears.

       5.      Enter a description of your changes if you like and choose OK.

A dialog window Activation appears. It allows you to activate immediately by building in the Component Build Service.

       6.      To build your DC at a later time, choose Cancel.

All changes are stored on the DTR server.

 

 

 

 

Leaving content frame