AJP Unit 3 QB Bank
AJP Unit 3 QB Bank
1. In RMI Architecture which layer Intercepts method calls made by the client/redirects these
calls to a remote RMI service?
2) Which is an object, acts as a gateway for the client side, all the outgoing requests are
routed through it and it resides at the client side and represents the remote object?
a. Stub
b. Skeleton
c. Both A & B
d. None of the above
a. Value
b. Reference
c. Value and Reference
d. None of the above
5) In a RMI Client Program, what are the exceptions which might have to handled?
A) RemoteException
B) NotBoundException
C) MalFormedURLException
D) All mentioned above
6) RMI Architecture consists of how many layers?
A) 5
B) 3
C) 4
D) 2
7. What is Cobra in the context of Java?
A) A new programming language developed by Oracle.
B) A testing framework for Java applications.
C) A command-line parser library in Java.
D) A Java module for advanced string manipulation.
11. In which phase of software development is Cobra in Java most likely to be utilized?
A) Design
B) Testing
C) Implementation
D) Deployment
12. What is the purpose of the Naming service in Java RMI (Remote Method Invocation)?
a. To manage user authentication
b. To provide a centralized registry for remote objects
c. To handle exception handling in distributed systems
d. To optimize network communication in Java applications
13. Which interface is used to bind an object to a name in the Java Naming and Directory
Interface (JNDI)?
a. RemoteObject
b. NamingService
c. javax.naming.NamingContext
d. javax.naming.Context
17. What does the -c option in the jar command stand for?
a) Create b) Compile c) Copy d) Compress
18. To include all files in the current directory when creating a JAR file, which command-line
option should be used?
a) -f b) -e c) -C d) -m
19. How can you specify the entry point (main class) for a JAR file during creation?
a) -m b) -e c) -main d) -entry
20. To update an existing JAR file with new files, which command-line option should be used?
a) -u b) -x c) -r d) -a
Part II (6 Marks)
1.Explain the concept of Remote Method Invocation (RMI) in Java.
Answer: Remote Method Invocation (RMI) is a Java API that allows an object to invoke methods
on an object running in another Java Virtual Machine (JVM). RMI enables the communication
between distributed Java applications, allowing objects in one JVM to invoke methods on
objects in another JVM. To use RMI, the objects must be remote objects, which means they can
be accessed from different JVMs. RMI handles the complexities of communication, including
parameter passing, serialization, and remote object activation.
2: How does RMI handle parameter passing between distributed objects?
Answer: RMI uses a process called serialization to handle parameter passing between
distributed objects. When a method is invoked on a remote object, the parameters of the
method are serialized (converted into a byte stream) before being sent over the network to the
remote JVM. The remote JVM then deserializes the parameters to reconstruct the original
objects. This process ensures that the objects can be transmitted between JVMs, maintaining
their state and structure.
3. Explain the steps involved in creating and using a remote object in RMI.
Answer:
Create the Remote Interface: Define an interface that extends the java.rmi.Remote interface.
This interface declares the methods that can be invoked remotely. Each method must declare
the RemoteException in its throws clause.
Implement the Remote Object: Create a class that implements the remote interface. This class
should extend java.rmi.server.UnicastRemoteObject to provide remote object functionality. The
methods of this class should handle the actual implementation of the remote methods.
Compile the Interface and Implementation: Compile both the remote interface and its
implementation using the javac compiler.
Generate Stub and Skeleton: Use the rmic tool to generate the stub and skeleton for the
remote object. The stub acts as a client-side proxy, and the skeleton acts as a server-side
mediator.
Start the RMI Registry: Start the RMI registry, which serves as a lookup service for remote
objects.
Instantiate and Bind the Remote Object: In the server program, create an instance of the
remote object, bind it to the RMI registry using Naming.bind(), and make it available for remote
invocation.
Look Up and Invoke Remote Object: In the client program, look up the remote object using
Naming.lookup(), obtain a reference to the remote interface, and invoke the remote methods
as if they were local.
These steps collectively enable the creation and usage of remote objects in RMI.
A Java Remote Method Invocation (RMI) application can make remote invocations over secure
SSL connections using custom socket factories. An application can export a remote object to use
an RMI socket factory that creates SSL sockets.
This tutorial shows you the steps to follow to implement and use a custom RMI socket factory.
A custom RMI socket factory is useful if
(1) your RMI client and server need to use sockets that encrypt or compress data, and/or
(2) your application requires different socket types for different remote objects.
RMI-IIOP
The Java RMI-IIOP specification was created to simplify the development of CORBA
applications, while preserving all major benefits. It was developed by Sun Microsystems and
IBM, combining features of Java RMI technology with features of CORBA technology.
6 Explain the concept of CORBA in Java and its role in distributed computing.
IIOP stands for Internet Inter-ORB Protocol, a standard protocol defined by the Object
Management Group (OMG) as part of the CORBA (Common Object Request Broker
Architecture) specification. It is designed to allow communication between different CORBA
Object Request Brokers (ORBs) over the Internet.
CORBA is a framework for enabling distributed computing, where objects residing on different
systems can interact with each other as if they were local. IIOP plays a crucial role in this
framework by providing the mechanism for communication between ORBs.
1. CORBA in Java:
o Java supports CORBA through the javax.rmi.CORBA package and Java IDL (Interface
Definition Language).
o CORBA allows Java applications to interact with objects written in other languages like
C++ or Python using the language-neutral IDL.
2. Role of IIOP:
o IIOP is the wire protocol that enables ORBs from different vendors to interoperate.
o In Java, when a Java object is exposed as a CORBA object (e.g., using Java RMI-IIOP),
communication between the client and server occurs over IIOP.
3. Java RMI-IIOP:
o Java Remote Method Invocation over IIOP (RMI-IIOP) integrates Java RMI with CORBA.
o This allows Java objects to be invoked remotely using IIOP, enabling interoperability
with CORBA-compliant systems.
o The rmic compiler in Java generates the necessary stubs and ties for enabling RMI-IIOP
communication.
Interoperability: Ensures that ORBs from different vendors can communicate seamlessly.
Distributed Objects: Enables Java objects to participate in distributed object systems using
CORBA.
Standardization: Follows the OMG standard for communication over networks.
IIOP is thus a cornerstone of CORBA's ability to provide a language-agnostic, platform-
independent distributed computing environment, with Java offering built-in support for working
with this protocol.
Object Activation: ORB is responsible for activating objects on the server side when they are
requested by clients. It ensures that the necessary object instances are created and made
available to serve client requests.
IIOP Protocol Handling: ORB uses the IIOP protocol to transmit requests and responses
between clients and servers. It encapsulates the communication details, allowing objects
implemented in different languages to communicate seamlessly.
Interface Definition: ORB uses Interface Definition Language (IDL) to define the interfaces of
distributed objects. It ensures that clients and servers understand each other's interfaces,
enabling interoperability.
In summary, ORB plays a central role in managing the communication and interaction between
distributed objects in a CORBA-based Java application.
9. Explain the concept of Naming Service in Java and its significance in distributed systems.
A naming service allows you to look up an object given its name. A naming service's
primary function is to map people friendly names to objects, such as addresses, identifiers, or
objects typically used by computer programs
Java.rmi.Naming class contains a method to bind, unbind or rebind names with a remote object
present at the remote registry. This class is also used to get the reference of the object present
at remote registries or the list of name associated with this registry.
import javax.naming.Context;
import javax.naming.InitialContext;
} catch (Exception e) {
e.printStackTrace();
}
}
}
Enterprise Applications: JNDI is heavily used in Java EE for locating application resources
like database DataSources, mail sessions, or external APIs.
Distributed Systems: RMI Registry or custom naming services facilitate the lookup of
services in distributed systems.
Microservices and Middleware: Naming services assist in service discovery in
distributed systems.
10. Describe the purpose and importance of JAR files in the context of Java development
A JAR file is a Java archive file format that bundles multiple files into a single file. This format is
primarily used for distributing Java applications and libraries.
1. Portability: JAR files are platform-independent, meaning they can run on any system
with a JVM installed.
2. Efficiency: By bundling multiple files into a single JAR, you can reduce the number of
files to manage and improve loading times.
3. Security: JAR files can be digitally signed to verify their authenticity and integrity.
4. Modularity: JAR files promote modularity by allowing you to break down your
application into smaller, reusable components.
5. Dependency Management: JAR files help in managing dependencies between different
components of your application.
The basic format of the command for creating a JAR file is:
1. Discuss the security considerations in Remote Method Invocation (RMI) and explain
the mechanisms provided by Java RMI for ensuring secure communication between
distributed components.
The RMI (Remote Method Invocation) is an API that provides a mechanism to create distributed
application in java. The RMI allows an object to invoke methods on an object running in another
JVM.
The RMI provides remote communication between the applications using two
objects stub and skeleton.
stub
The stub is an object, acts as a gateway for the client side. All the outgoing requests are
routed through it. It resides at the client side and represents the remote object. When the
caller invokes method on the stub object, it does the following tasks:
skeleton
The skeleton is an object, acts as a gateway for the server side object. All the incoming
requests are routed through it. When the skeleton receives the incoming request, it does the
following tasks:
Codebase Integrity: Ensuring the integrity of the classes being downloaded from remote
codebases is crucial to prevent malicious code execution.
Authentication: Verifying the identity of the parties involved in the RMI communication to
prevent unauthorized access.
Data Integrity and Confidentiality: Ensuring that the data exchanged between the client and
server is not tampered with and is kept confidential during transmission.
Access Control: Defining and enforcing access control policies to restrict certain operations or
resources to authorized entities.
Firewall and Network Security: Securing the network infrastructure to prevent unauthorized
access and protect against various network-based attacks.
Java RMI provides several mechanisms to address these security considerations:
Codebase Annotation: Using the codebase annotation in the remote interface or
implementation class to specify the location from which classes should be loaded. This helps in
maintaining codebase integrity.
Java Security Manager: Configuring and using the Java Security Manager to control the actions
performed by the RMI system, such as allowing or denying certain operations.
SSL/TLS: Employing Secure Socket Layer (SSL) or Transport Layer Security (TLS) for encrypted
communication, ensuring data integrity and confidentiality.
Custom Security Managers: Implementing custom security managers to enforce specific access
control policies.
Digital Signatures: Using digital signatures to verify the authenticity and integrity of
downloaded class files.
By combining these mechanisms, Java RMI provides a comprehensive approach to secure
communication in distributed systems.
2. Explain RMI (Remote Method Invocation) and custom sockets in Java. Discuss how they
are used in distributed computing.
RMI (Remote Method Invocation) and custom sockets are two powerful tools in Java for building
distributed systems. They each offer distinct approaches to inter-process communication, catering to
different use cases and complexities.
RMI provides a high-level abstraction for distributed object computing. It allows you to write
Java objects that can be invoked remotely, as if they were local objects. Key features of RMI
include:
Custom sockets provide a lower-level approach to network communication, giving you more
control over the underlying network protocols. You can create custom socket implementations to
tailor the communication to specific needs, such as:
Custom Protocols: You can define your own protocols for efficient and optimized
communication.
Security: You can implement custom security measures, such as encryption and
authentication, to protect sensitive data.
Performance Optimization: You can fine-tune performance by optimizing the socket
implementation for specific use cases.
The choice between RMI and custom sockets depends on several factors:
Complexity: RMI is simpler to use, while custom sockets require more programming
effort.
Performance: Custom sockets can offer better performance, but RMI can be sufficient
for many applications.
Security: Both RMI and custom sockets can provide security, but custom sockets offer
more flexibility in implementing custom security measures.
Protocol Flexibility: Custom sockets allow for more flexibility in defining custom
protocols, while RMI is more limited in this regard.
3. Explain the significance of IIOP (Internet Inter-ORB Protocol) in the context of CORBA. How
does IIOP enable interoperability in distributed systems, particularly in Java? Provide
examples of how Java ORBs use IIOP for communication.
IIOP, or Internet Inter-ORB Protocol, is a protocol used by CORBA for communication between
Object Request Brokers (ORBs) over the Internet. It plays a crucial role in achieving
interoperability between different CORBA implementations and platforms.
Key Points:
Interoperability: IIOP enables interoperability by providing a standardized protocol for
communication between ORBs. This means that ORBs from different vendors can communicate
seamlessly.
Internet Connectivity: IIOP is designed for communication over the Internet, allowing
distributed objects to interact across diverse networks.
Language Neutrality: IIOP supports language neutrality, allowing objects written in different
programming languages to communicate. This is essential for heterogeneous distributed
systems.
Examples of Java ORBs using IIOP:
Java IDL: Java's Interface Definition Language (IDL) supports IIOP, making it compatible with
CORBA implementations across various languages.
ORBacus and JacORB: These are examples of Java ORBs that use IIOP for communication,
providing interoperability with CORBA implementations in other languages.
Scenarios:
Multi-Language Systems: IIOP is particularly beneficial in scenarios where a distributed system
involves components implemented in different programming languages, ensuring seamless
communication.
Object Activation: ORB is responsible for activating objects on the server side when they are
requested by clients. It ensures that the necessary object instances are created and made
available to serve client requests.
IIOP Protocol Handling: ORB uses the IIOP protocol to transmit requests and responses
between clients and servers. It encapsulates the communication details, allowing objects
implemented in different languages to communicate seamlessly.
Interface Definition: ORB uses Interface Definition Language (IDL) to define the interfaces of
distributed objects. It ensures that clients and servers understand each other's interfaces,
enabling interoperability.
In summary, ORB plays a central role in managing the communication and interaction between
distributed objects in a CORBA-based Java application.
5. Explain the concept of Naming Service in Java and its significance in distributed systems.
The Naming Service in Java refers to the Java Naming and Directory Interface (JNDI), which is
a standard Java API for interacting with naming and directory services. It plays a crucial role in
distributed systems by providing a unified interface for accessing various naming and directory
services, such as DNS, LDAP, and RMI registry.
Unified Naming Interface: The Naming Service offers a consistent and unified interface for
applications to look up and bind objects within a distributed environment. This abstraction
allows developers to write code that is independent of the underlying naming and directory
service implementation.
Object Binding: One of the primary functions of the Naming Service is to bind objects to names,
making them accessible to other components or applications in the distributed system. This
enables the location and interaction with remote objects seamlessly.
Dynamic Discovery: In distributed systems, services and resources may come and go. The
Naming Service allows for dynamic discovery of objects and services, enabling applications to
adapt to changes in the network environment without requiring extensive modifications to the
code.
Support for Various Naming Systems: JNDI supports a variety of naming and directory services,
making it versatile for different distributed scenarios. Whether an application needs to interact
with a simple RMI registry or a complex LDAP directory, the Naming Service provides a
consistent way to access these services.
Scalability and Interoperability: The Naming Service enhances the scalability and
interoperability of distributed applications. It allows components written in different languages
or running on different platforms to communicate seamlessly by providing a standard way to
locate and access distributed objects.
6. Explain the concept of JAR files in Java and discuss their significance in Java development.
JAR (Java Archive) files play a crucial role in Java development as they provide a way to
package multiple files into a single archive. This enhances the organization, distribution, and
deployment of Java applications. Here's an overview of the concept of JAR files and their
significance:
2. Classpath Management:
Definition: JAR files are often used to manage the classpath in Java applications.
Significance: Including dependencies in JAR files simplifies classpath management, ensuring
that all required classes and resources are available to the application at runtime.
3. Module Organization:
Definition: JAR files can be organized as modules, containing packages and classes related to
specific functionalities.
Significance: Modularizing code using JAR files enhances code organization, improves
maintainability, and facilitates code reuse across different projects.
4.Library Distribution:
Definition: Many Java libraries and frameworks are distributed as JAR files.
Significance: JAR files make it easy to distribute and share libraries, enabling developers to
incorporate external functionalities into their projects seamlessly.
5.Executable JARs:
Definition: An executable JAR file contains a manifest file specifying the main class to be
executed.
Significance: Executable JARs simplify the deployment of standalone Java applications,
providing a convenient way to distribute and run Java programs without explicitly specifying the
classpath.