- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Deployment descriptor in Java
Listing 3.4 Deployment descriptor Painting PDF417 In Java Using Barcode maker for Java Control to generate, create PDF 417 image in Java applications. www.OnBarcode.comPDF-417 2d Barcode Decoder In Java Using Barcode reader for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.com<ejb-jar> <enterprise-beans> <!-- =========[ ContainerManaged Bean ]======== --> <entity> Declares the EJB that <ejb-name>containerManaged</ejb-name> will use container<home>containerManaged.EquityHome</home> managed persistence <remote>containerManaged.Equity</remote> <ejb-class>containerManaged.EquityBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>EquityBean</abstract-schema-name> <cmp-field> Declares the persistent <field-name>symbol</field-name> fields of the bean </cmp-field> <cmp-field> <field-name>description</field-name> Indicates the use of the </cmp-field> 2.0 specification and <cmp-field> declares the schema name <field-name>lastTrade</field-name> </cmp-field> <cmp-field> <field-name>change</field-name> </cmp-field> <cmp-field> <field-name>volume</field-name> </cmp-field> <cmp-field> <field-name>marketCap</field-name> </cmp-field> <cmp-field> <field-name>pe</field-name> PDF 417 Drawer In Java Using Barcode drawer for Java Control to generate, create PDF 417 image in Java applications. www.OnBarcode.comPrinting Data Matrix ECC200 In Java Using Barcode printer for Java Control to generate, create DataMatrix image in Java applications. www.OnBarcode.comWorking with data
Encode GTIN - 128 In Java Using Barcode drawer for Java Control to generate, create UCC - 12 image in Java applications. www.OnBarcode.comEAN / UCC - 13 Creator In Java Using Barcode creator for Java Control to generate, create GS1 - 13 image in Java applications. www.OnBarcode.com</cmp-field> <cmp-field> <field-name>avgVolume</field-name> Declares the primary </cmp-field> key field of the bean <primkey-field>symbol</primkey-field> </entity> <!-- =========[ ContainerManaged Bean ]======== --> </enterprise-beans> <assembly-descriptor> </assembly-descriptor> </ejb-jar> ECC200 Encoder In Java Using Barcode generation for Java Control to generate, create ECC200 image in Java applications. www.OnBarcode.comEncode Case Code In Java Using Barcode generation for Java Control to generate, create UPC Case Code image in Java applications. www.OnBarcode.comDiscussion
Paint PDF 417 In VS .NET Using Barcode generation for Reporting Service Control to generate, create PDF 417 image in Reporting Service applications. www.OnBarcode.comDecode PDF 417 In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comAs you can see in the EquityBean example, the source for a CMP bean is noticeably different from that of a BMP bean. First of all, the methods will not contain any persistence code, like JDBC connections or SQL statements. Also, a CMP entity bean has a much more descriptive deployment descriptor than a BMP entity bean. However, like a BMP bean, it must declare its persistence type. In this case, it should be declared Container. Similarly, the deployment descriptor should also tell the container to use the EJB 2.0 specification (which is what this recipe describes). After declaring the bean to be a 2.0 CMP entity bean, you should describe the persistent fields and schema used by the bean. Indicate each field that will be persisted with a <cmp-field/> tag. The EJB container will generate a concrete subclass of your abstract bean that implements the abstract methods to actually perform the persistence and loading of the bean data as needed. The schema and persistent fields are mapped to an actual database table in a vendor-specific manner, usually with a vendor deployment descriptor for the bean. Check your vendor s documentation for more information on what you need to do. Typically, application servers require you to provide an additional XML descriptor file. For example, Weblogic requires you to build two files: weblogic-ejb-jar.xml and weblogic-cmp-rdbms-jar.xml. Lastly, you should declare which persistent field is the primary key for this entity bean. When using entity beans in your application, you should always encapsulate access to them through a session bean. Not only does this separate your clients from the data layer, but it lets you provide better security, transaction management, and performance. For instance, when you access your entity beans through a session facade (see recipe 3.15), your entity beans need only implement local Painting Code128 In .NET Framework Using Barcode generator for Visual Studio .NET Control to generate, create USS Code 128 image in Visual Studio .NET applications. www.OnBarcode.comCode 128A Maker In Java Using Barcode creator for Eclipse BIRT Control to generate, create Code 128B image in BIRT applications. www.OnBarcode.comUsing different data sources for different users
Quick Response Code Encoder In None Using Barcode drawer for Office Excel Control to generate, create QR Code ISO/IEC18004 image in Microsoft Excel applications. www.OnBarcode.comCreate PDF-417 2d Barcode In None Using Barcode creator for Software Control to generate, create PDF 417 image in Software applications. www.OnBarcode.cominterfaces. This prevents any remote client from finding your entity data without first passing through the session bean layer and being validated. Code 39 Extended Scanner In Visual Basic .NET Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comBarcode Generator In None Using Barcode generation for Online Control to generate, create Barcode image in Online applications. www.OnBarcode.comSee also
Recognizing Barcode In None Using Barcode reader for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comGenerate ECC200 In Objective-C Using Barcode creator for iPad Control to generate, create DataMatrix image in iPad applications. www.OnBarcode.com2.3 Keeping your EJB deployment descriptor current 3.4 Using a database sequence to generate primary key values for entity beans 3.5 Using a compound primary key for your entity beans EAN 13 Maker In .NET Framework Using Barcode printer for .NET framework Control to generate, create EAN-13 image in .NET framework applications. www.OnBarcode.comBarcode Scanner In C#.NET Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications. www.OnBarcode.com3.3 Using different data sources for different users
Problem
Within an EJB, you would like to provide different data sources to different user sessions.
Background
In your application, you need the ability to provide a different database view (or database) depending on the current user. This is one way to prevent unauthorized users from updating restricted data. Since the EJB security model provides for the discovery of the invoking client, you can easily determine a user s identity and assigned roles. Programmatically restricting data access to specific users can make your code less flexible and maintainable. Recipe
In order to switch data sources for a particular user, you must first determine which user is calling an EJB method. Inside the UserSpecificDBBean session bean shown in listing 3.5, the getConnection() method determines the invoking user and returns a JDBC connection based on the retrieved value. Listing 3.5 UserSpecificDBBean.java
public class UserSpecificDBBean implements SessionBean { private SessionContext ctx; public void setSessionContext(SessionContext ctx) { this.ctx = ctx; } public Connection getConnection() throws SQLException{ String srcName = null; Working with data
InitialContext initCtx = null; try { Principal p = this.ctx.getCallerPrincipal(); String username = p.getName();
|
|