Saturday, February 3, 2007

Explain RMI Architecture?

RMI uses a layered architecture, each of the layers could be enhanced or replaced without affecting the rest of the system. The details of layers can be summarised as follows:

Application Layer: The client and server program
Stub & Skeleton Layer: Intercepts method calls made by the client/redirects these calls to a remote RMI service.
Remote Reference Layer: Understands how to interpret and manage references made from clients to the remote service objects.
Transport layer: Based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies.


SOURCE : www.referjava.com

Does RMI-IIOP support dynamic downloading of classes?

No, RMI-IIOP doesn't support dynamic downloading of the classes as it is done with CORBA in DII (Dynamic Interface Invocation).Actually RMI-IIOP combines the usability of Java Remote Method Invocation (RMI) with the interoperability of the Internet Inter-ORB Protocol (IIOP).So in order to attain this interoperability between RMI and CORBA,some of the features that are supported by RMI but not CORBA and vice versa are eliminated from the RMI-IIOP specification.

SOURCE : www.referjava.com

How many types of protocol implementations does RMI have?

RMI has at least three protocol implementations: Java Remote Method Protocol(JRMP), Internet Inter ORB Protocol(IIOP), and Jini Extensible Remote Invocation(JERI). These are alternatives, not part of the same thing, All three are indeed layer 6 protocols for those who are still speaking OSI reference model.

SOURCE : www.referjava.com

What are the services in RMI ?

An RMI "service" could well be any Java method that can be invoked remotely. The other service is the JRMP RMI naming service which is a lookup service.

SOURCE : www.referjava.com

What is the difference between RMI & Corba ?

The most significant difference between RMI and CORBA is that CORBA was made specifically for interoperability across programming languages. That is CORBA fosters the notion that programs can be built to interact in multiple languages. The server could be written in C++, the business logic in Python, and the front-end written in COBOL in theory. RMI, on the other hand is a total Java solution, the interfaces, the implementations and the clients--all are written in Java.

RMI allows dynamic loading of classes at runtime. In a multi-language CORBA environment, dynamic class loading is not possible. The important advantage to dynamic class loading is that it allows arguments to be passed in remote invocations that are subtypes of the declared types. In CORBA, all types have to be known in advance. RMI (as well as RMI/IIOP) provides support for polymorphic parameter passing, whereas strict CORBA does not. CORBA does have support for multiple languages which is good for some applications, but RMI has the advantage of being dynamic, which is good for other applications.




SOURCE : www.referjava.com

Explain RMI Architecture?

RMI uses a layered architecture, each of the layers could be enhanced or replaced without affecting the rest of the system. The details of layers can be summarised as follows:


Application Layer: The client and server program
Stub & Skeleton Layer: Intercepts method calls made by the client/redirects these calls to a remote RMI service.
Remote Reference Layer: Understands how to interpret and manage references made from clients to the remote service objects.
Transport layer: Based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies.

SOURCE : www.referjava.com

Will there be debugging mechanisms built into RMI?

RMI supports a simple call-logging facility for debugging. But there are no current plans to support a full-featured, interactive, remote debugger.

SOURCE : www.referjava.com

Does RMI require me to use an HTTP server?

No. You can set your java.rmi.server.codebase property to use any valid URL protocol, such as file or ftp. Using an HTTP server just makes your life simpler by providing an automated mechanism for class file downloading.

SOURCE : www.referjava.com

difference between MessageDrivenBeans & Stateless Session ?

In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways:

Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls.

Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic.

Note: Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary.

The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls.

SOURCE : www.referjava.com

Brief description about local interfaces?

EJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong feature in support of a goal of component reuse in J2EE.

Many developers are using EJBs locally -- that is, some or all of their EJB calls are between beans in a single container.

With this feedback in mind, the EJB 2.0 expert group has created a local interface mechanism. The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container. This does not involve the overhead involved with RMI like marshalling etc. This facility will thus improve the performance of applications in which co-location is planned.

Local interfaces also provide the foundation for container-managed relationships among entity beans with container-managed persistence.

SOURCE : www.referjava.com

Can you control when passivation occurs?

The developer, according to the specification, cannot directly control when passivation occurs. Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction. So using transactions can be a a strategy to control passivation. The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic. Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls. Taken from the WebLogic 6.0 DTD -”The passivation-strategy can be either “default” or “transaction”. With the default setting the container will attempt to keep a working set of beans in the cache. With the “transaction” setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation).

SOURCE : www.referjava.com

How EJB Invocation happens?

Retrieve Home Object reference from Naming Service via JNDI. Return Home Object reference to the client. Create me a new EJB Object through Home Object interface. Create EJB Object from the Ejb Object. Return EJB Object reference to the client. Invoke business method using EJB Object reference. Delegate request to Bean (Enterprise Bean).

SOURCE : www.referjava.com

What is EJB ?

The three types of EJBs are: (1) session beans perform processing, (2) entity beans represent data, which can be a row or a table in a database, and (3) message driven beans are generated to process Java Messaging Service (JMS) messages.

SOURCE : www.referjava.com

Downsides of Ajax

Limited Capabilities: Some Ajax applications are certainly doing things people never dreamed were possible on the web, but there are still substantial restrictions of the web platform. For example: multimedia capabilities, local data storage, real-time graphics, interaction with hardware such as printers and webcams. Support for some of these are improving in recent browsers, some can be achieved by delegating to Flash, but many are simply not possible, and if required, would rule out Ajax.
Performance Concerns: Constant interaction between browser and server can make an application feel unresponsive. There are, however, quite a few well-known patterns for performance optimisation such as browser-side caching. These usually suffice, even for fast-paced applications like stock trading, but Ajax still might not work for really time-critical applications such as machine control.
Internet Access Required: The user can't access an Ajax application in the absence of a network connection.
Second Programming Language: Serious Ajax applications require some knowledge of Javascript. Many developers are discovering that Javascript is actually a more capable language than at first assumed, but there is nevertheless an imposition to use a language different to that on the server-side.
Easily Abused: As with any powerful technology, Ajax concepts can be abused by careless programmers. The patterns on this site are intended to guide developers towards more usable solutions, but the fact remains that Ajax isn't always used in a manner that supports usability.

SOURCE : www.referjava.com

typical Ajax lifecycle within the browser:

Visit: The user visits a site the usual way, i.e. by clicking on a link or typing a URL.
Initialisation The page initially loads. Callbacks are established to handle user input, a loop might be established to continously refresh page elements.
Event Loop:
Browser Event An event occurs, such as a keypress.
Server Request The browser sends a request to the server.
...Server processes the event>
Server Response A moment later, the server responds, and the response is passed into a request callback function, one that was specified when the request was issued.
Browser Update The request callback function updates the DOM, including any Javascript variables, according to the response.

Back to top


Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

SOURCE : www.referjava.com

Definition for AJAX

AJAX is a combination of technologies (Javascript/XML/HTML) that work together to make Websites that update without refreshing the entire page. With AJAX you can update portions of a web page at a time.

Probably the most critical component of AJAX is the "XMLHttpRequest object". It allows the dynamic transfer of information with the need for a full page refresh. Sites like Google Mail (Gmail.com) and Google Maps (google.com/maps) have really made AJAX popular.

SOURCE : www.referjava.com

What is the importance in context in jdbc connection pools?

Connection pooling is one of the ways to increase the performance of the jdbc connectivity in client server technology. It optimizes the time taken acquire a new connection on every request by maintaining a pool of connections by the connection pool server which serves the connections to the requested objects and maintains the acurate status of each connection.

SOURCE : www.referjava.com

what is savepoint?

Save point is a feature using which we can save status of the transaction to a particular extent.so that if anytime we have lost a transaction we can get it back using save point.

SOURCE : www.referjava.com

What is metadata?

a. This is the Data Information that a Resultset has fetched. For Example I had a resultset containig all the records from a table of 3 columns say CA,CB, CC. Metadata will all the underlined info about the table and the columns that has been fetched.

b. Basically, Metadata is data about data. In context of JDBC, there may be two types of metadata.

1. Describing information about the Resultset object. i.e, if u have applied a query that fetches some result. this metadata describes information about how many columns have been fetched, their names etc.

2. Second one describes about the database connection

c. Meta Data- is information that describes about structure and properties of our data. When we define a table we specify each columns name, type of data it holds and restrictions imposed (Constraints) and who owns it. This Information in JDBC Context is called MetaData.In JDBC we have two types of Meta Data
(i) ResultSet MetaData
(ii) (ii) DataBase MetaData
(iii) (i)ResultSet MetaData is information about data contained in ResultSet(ii)
DataBase MetaData is Data about Data

d. A single application can have one or more connections with a single database, or it can have connections with many different databases. A user can get information about a Connection object's database by invoking the Connection.getMetaData method. This method returns a DatabaseMetaData object that contains information about the database's tables, the SQL grammar it supports, its stored procedures, the capabilities of this connection, and so on.

SOURCE : www.referjava.com

which is the best driver among the 4 jdbc drivers?

1.
a. Type 4 driver is the best driver among 4 drivers because it need not be load other API's, because the code is developed only in java language, so other language API's are not need.

b. Type 4 is the best driver because it directly interact with database without any usage od intermediate serversor other technology.Because of this reason Type-4 driver is also called Thin Driver

c. . Use Type 4 driver for applet to database communication.

2. Use Type 2 driver for two tiered applications for communication between java client and the database that gives better performance when compared to Type1 driver

3. Use Type 1 driver if your database doesn't support a driver. This is rare situation because almost all major databases support drivers or you will get them from third party vendors.

4.Use Type 3 driver to communicate between client and proxy server ( weblogic, websphere etc) for three tiered applications that gives better performance when compared to Type 1 & 2 drivers.

there, the order in which the drivers can be used is 4213,

SOURCE : www.referjava.com

why do we use prepared statement when statement is there

a. Prepared statement is a precompiled statement, it is mailnly used for the speed up the prcoss of inserting/updating/deleting when there is a bulk processing.

b. Actually when u submit a simple statement to the database, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS server parses it and sends back the result so here a lot of time is wasted and because the statement is again parsed though it has been sent twice or thrice it consumes a lot of time and response will be slow. Prepared Statement is used when u want to execute a statement object many times. When u submits a PreparedStatement the DBMS server parses it and creates an execution plan. This e-plan can be used when u again send the same statement to the database. That is the DBMS server zest executes the compiled statement rather that executing it from first, hence we get a precompiled statement. And also the advantage of using this PreparedStatement is it is used to send dynamic sql statements, which u can give values later than giving the values at the time of creation.

c. Prepared Statement is Pre-compiled class, but Statement is not.So in PreparedStatement the execution will be faster.

SOURCE : www.referjava.com

how to store images in a database?

a. We can store the image in the database using the blob (binary large object) data type, where the image is stored in the form of the streams...

b. Using binary streams (i.e. getBinaryStream () ,setBinaryStream()).But it is not visable in database ,it is stored in form of bytes ,to make it visable we have to use any one frontend tool.

SOURCE : www.referjava.com

How to get the resultset of stored Procedure ?

a. By invoking the getObject on the CallableStatement.CallableStatement
proc = conn.prepareCall("{ ? = call " + functionSql + "
}");proc.registerOutParameter(1, Types.OTHER); proc.execute();ResultSet results =
(ResultSet) proc.getObject(1);

b. Involve getResultSet() method of the callableStatement object that is
inherited from java.sql.Statement interface.

SOURCE : www.referjava.com

Difference between Type-2 and Type-3 driver ?

a. Type 2 driver is part Native-part Java driver. It is also one of the thin drivers. After the java calls are converted into JDBC calls by using the JDBC API, and those calls use the vendor specific API and connected to Database to get the results.
Type 3 is Medium Access Sub Layer driver. After the calls are converted to JDBC calls by using JDBC API, they are forwarded to another driver(either type 2 or type 4) and from there it goes to the Database to get the results.

b. Type-2 driver is Part Java Part Native Driver. This driver is a mixture of Jdbc driver and Vendor speciifc driver . You not only use ODBC to communicate with DataBase. You can also use Vendor specif Apis like Oracle Call Level Interface (OCI) that is supplied by Oracle.When an application is sent to the Jdbc driver this driver sends this request to Vendor specific api and that inturn communicates with the Database.
Type-3 driver is Intermediate Access Protocol Driver where as in this case when an application is sent to the JDBC Driver and that is sent to another intermediate acess servers and that inturn is sent to another native driver (can be an Type-2 driver) and then the request is sent to Database.

SOURCE : www.referjava.com

What is Connection Pooling?

a. Connection pooling is the process of reusing the database connections created between the application and the database, by then increasing the performance of the application.
Suppose, that there is table in the database, called 'employer', if a objects asks the application server to create a connection between the table and the object, the appServer creates, but it does not throw away the connection, it keeps the connection information in a pool, if again the object requires to connect to the table, it doesn't require to create a new connection as the connection available in the connection pool can be reused. Hence increase in performance.

b. Connection Pooling is a technique used for sharing the server resources among requested clients. It was pioneered by database vendors to allow multiple clients to share a cached set of connection objects that provides access to a database.

c. Connection pooling is a place where a set of connections is kept and is used by the different programers with out creating conncections tithe database (it means there is a ready made connection a available for the programmers where he can use). After using the connection he can send back that connection to the connection pool. Number of connections in connection pool may vary.

d. Getting connection and disconnecting are tasks by itself, which costs to the application performance, so we should avoid it. To be more precise, depending of the Max & Min connections parm set in the specific Appserver config, it intially either gets the min set of ready to connections or would be request based till the max connections are used. Once DB operations are done, the free DB connections are re-used.

e. Getting connection and disconnecting are tasks by itself, which costs to the application perfomance, so we should aovid it. To be more precise, depending of the Max & Min connections parm set in the specific Appserver config, it intially either gets the min set of ready to connections or would be request based till the max connections are used. Once DB operations are done, the free DB connections are re-used.

f. Connection pooling means set of connections is available to connect, after use this connection, disconnect it then others can use it. It reduces the time, and it can be eusable. User can use any number of connections.

SOURCE : www.referjava.com

Diff btw TYPE_SCROLL_INSENSITIVE, and TYPE_SCROLL_SENSITIVE?

a result set that is TYPE_SCROLL_INSENSITIVE does not reflect
changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE
does.

SOURCE : www.referjava.com