BCSCCS706 R01

download BCSCCS706 R01

of 18

Transcript of BCSCCS706 R01

  • 8/6/2019 BCSCCS706 R01

    1/18

    Lab Manual

    Component Based Development LAB

    Subject Code: BCSCCS 706 R01/ BICCIC 706 R01/ BITCIT 706 R01

    List of Exercises

    1.Create a greeting message, using COM component in VB.

    2. Create a Rapid application Development using ActiveX component in VB .

    3.Create a application for arithmetic operations using COM+ component in

    VB.Net.

    4.Create Database connection using ADO Component in ASP.

    5.Create Database connection using ADO.net Component in ASP.net

    6.Create a session Bean using J2ee.

    7. Create an Entity Bean using J2ee.

    8. Create a program to maintain session using Session Bean in EJB.

    9. Create a inter process communication between the components using

    MESSAGE DRIVEN BEAN .

    10. Create intra communication using any Component..

  • 8/6/2019 BCSCCS706 R01

    2/18

    1. Create a greeting message, using COM component in VB.

    Procedure

    1. Create a COM Component by using Class Library template

    2. Name the Component

    3. Provide the Necessary Code inside the Component

    4. Build the Component to get the DLL

    5. Create a New Window Application with a Button

    6. Right click the WindowApplication and add a reference to the component

    dll

    7. Create an object for the component class and access the required method

    via button control

    PreLab: Working with interfaces and controls available in VB.

  • 8/6/2019 BCSCCS706 R01

    3/18

    2. Create a Rapid application Development using ActiveX component in VB.

    1. Create a ActiveX Component by using Windows Control Library template

    2. Customize the new Component using the existing controls

    3. Build the new component to get the DLL

    4. Right click the Toolbox and select the Choose item option and against the

    new control click the browse button and pick the required dll

    5. New control will be visible in the toolbox

    6. Create a new application to deploy the newly created Component

    PreLab: Create a new control and converting into dll in VB.

  • 8/6/2019 BCSCCS706 R01

    4/18

    3.Create a application for arithmetic operations using COM+ component

    in VB.Net.

    Procedure

    COM+ transactional services

    1. Open Visual Studio .NET.

    1. Create a new class library project named prjEnterprise in Visual Basic .NET.Visual Basic .NET creates a public class that is named Class1 and renames it to

    clsES.2. Add a reference to the project to the System.EnterpriseServices library. In theSolution Explorer window, right-click the References folder, and then select AddReference from the shortcut menu. On the .NET tab, scroll until you locate

    System.EnterpriseServices. Double-click System.EnterpriseServices, make sure

    that System.EnterpriseServices appears in the Selected Components window, andthen click OK.

    3. Use the Imports statement for the System.EntpriseServices namespace. Thesestatements must appear prior to any other statements in your class file:

    4. Add code for Addition, subtraction, Multipilcation and division inside the class1

    5. Open a Visual Studio .NET command prompt, clickStart, clickPrograms, click

    Microsoft Visual Studio .NET, and then clickVisual Studio .NET Tools.6. At the command prompt, type sn.exe -k snEnterprise.snk to give your assembly a

    strong name.

    For more information about signing assemblies with strong names, refer to the

    .NET Framework SDK documentation.

    7. Copy snEnterprise.snk to the project folder.8. In AssemblyInfo.vb, add the following line of code before or after other

    Assembly attribute statements:

    9.

    10.Build the COM+ component

    11.Add a new console application named testES to your solution, so that the solutioncontains both the testES project and the prjEnterprise project. To add the new

    project, clickNew on the File menu, and then select Project.12.A New Project dialog box appears. Select the Visual Basic folder in the Project

    Types pane, and then select Console Application from the templates. In the

    Name box under the Templates pane, type testES, which is the name of theproject. Make sure that the Add to Solution button, which appears at the bottom

    of the dialog box, is selected. ClickOK to add this project to the solution.

  • 8/6/2019 BCSCCS706 R01

    5/18

    13.In order for testES to test clsES, you must add a reference. In the Solutionswindow, right-click the References folder that is under the project testES, which

    you just added. Select Add Reference. An Add Reference dialog box appears.

    14.Select the Projects tab, and then double-clickprjEnterprise. A reference shouldappear in Selected Components, which is in the lower part of the dialog box.

    ClickOK to add this reference to this project.15.Right-click the console application, testES, and then select Set as StartupProject.

    16.On the Debug menu, select Windows. On the submenu, select Immediate. Thisensures that the immediate window is visible.

    17.Create an Instance of the COM+ component inside the code module and accessthe Arithmetic functions

    PreLab : Create a simple Component with services and add its reference

    to link with your application.

  • 8/6/2019 BCSCCS706 R01

    6/18

    4.Create Database connection using ADO Component in ASP.

    The ADODB.Connection object opens up an ODBC or OLEDB connection to adatabase through database drivers so you can do something with the database.

    You use it by first creating an instance of the object:

    When you are finished up with the connection it is a good idea to clean up:

    1. Now objconn is just a reference to the connection, so really it can be called anything,

    but the ususal name is conn or objConn. The next step is to open up a database. You cando this by either using a Data Source Name(DSN) or a connection string. Most

    commonly developors use a connection string because a DSN is requires setup by the

    administrator. A DSN is really just a shortcut name for a connection string. But with a

    connection string, you can move your database around without having to change theDSN.

    2. There are two connection strings. One uses ODBC the other uses OLEDB. We will use

    OLEDB since it is faster an simpler.

    t uses the Server.MapPath() function to get the physical path. (i.e.

    c:\w3svc\mypage\mydata.mdb\). When using a password protected database, do this:

    3. And finally, you have to use the connection string to open up a connection to the

    database by using the open property:

    To retrieve information from a database without using RecordSet's, you can use theconnection member object execute(). Execute() executes a SQL(said "sequel") statement.

    If you don't know how to form a SQL statement, Now here's and example of using the

    execute() function.

    4. Now you can use a WHILE loop to go though the records and print them out.

    Or if just want to delete,insert,or modify records you don't need to create rs. You can just

    do this.

    PreLab : Create a VB application and connect it to the MSACCESS

    database through ODBC and OLEBD drivers.

  • 8/6/2019 BCSCCS706 R01

    7/18

    5. Create Database connection using ADO.net Component in ASP.net

    The purpose of creating a SqlConnection object is so you can enable other ADO.NET

    code to work with a database. Other ADO.NET objects, such as a SqlCommand and a

    SqlDataAdapter take a connection object as a parameter. The sequence of operations

    occurring in the lifetime of a SqlConnection are as follows:

    1. Instantiate the SqlConnection.

    2. Open the connection.

    3. Pass the connection to other ADO.NET objects.

    4. Perform database operations with the other ADO.NET objects.

    5. Close the connection.

    PreLab: Create a simple Login application using ASP.net

  • 8/6/2019 BCSCCS706 R01

    8/18

    6. Create a session Bean using J2ee.

    1 Create a Remote Interface of the bean2 Create Home Interface of the bean3 Complete the Bean Implementation by deriving from Session Bean

    class

  • 8/6/2019 BCSCCS706 R01

    9/18

  • 8/6/2019 BCSCCS706 R01

    10/18

    7. Create an Entity Bean using J2ee.

  • 8/6/2019 BCSCCS706 R01

    11/18

  • 8/6/2019 BCSCCS706 R01

    12/18

    @Entity

    public class Contact implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private String name;private String email;

    private String phone;

    private String city;

    private String country;

    PreLab: Try to create various interfaces and utilize the same in yourapplication.

  • 8/6/2019 BCSCCS706 R01

    13/18

    8. Create a program to maintain session using Session Bean in EJB.

    Procedure

    1. Create a Stateful session bean maintaining the login name, time of login,duration of working.

    2. Ensure that, at the time of logout the details of the user are stored in thepersistent storage

    PreLab: Create a simple bean and add its reference to your application.

  • 8/6/2019 BCSCCS706 R01

    14/18

    9. Create a inter process communication between the components using

    MESSAGE DRIVEN BEAN .

    public class NewContactMessageBean implements MessageListener {

    @Resource

    MessageDrivenContext messageDrivenContext;

    2. Introduce EntityManager, to create new contact into the database, by right clicking onthe source editor and selecting Persistence > Use Entity Manager. This will add the

    following code:

    @PersistenceContext

    private EntityManager em;

    This will also add a new method:

    public void persist(Object object) {

    em.persist(object);

    }

  • 8/6/2019 BCSCCS706 R01

    15/18

    Rename this method as save(Object object) as follows:

    public void save(Object object) {

    em.persist(object);

    }

    3. Method onMessage needs to be modified to add the business logic to store the new

    contact into the database as follows:

    public void onMessage(Message message) {

    try {

    ObjectMessage objectMessage = (ObjectMessage) message;

    Contact contact = (Contact) objectMessage.getObject();

    save(contact);

    } catch (JMSException ex) {

    messageDrivenContext.setRollbackOnly();

    }

    }

    PreLab: Create more than one Bean and utilize the same to yourapplication.

  • 8/6/2019 BCSCCS706 R01

    16/18

    10. Create intra communication using any Component.

    Procedure

    1. Create COM Component by using Class Library template

    2. Name the Component

    3. Provide Two classes with their own codes

    4. Build the Component to get the DLL

  • 8/6/2019 BCSCCS706 R01

    17/18

    PreLab: Create intra communication using MDB in EJB.

  • 8/6/2019 BCSCCS706 R01

    18/18

    Additional Exercises in CBD

    Development of simple COM components in VB and use them in differentapplications

    Deploying EJB for simple purchase application Deploying RMI client and server application Creation of DLL in VB and deploy it in java Naming services in CORBA DSI and DII in CORBA Inter ORB in Comm ( IIOP,IOR) jac ORB and visibroker in ORB Studying J2EE server Simple applications using CORBA