advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Tutorials : An Introduction to Remote Method Activation (ROA), Part 2< :

An Introduction to Remote Method Activation (ROA), Part 2

by Anghel Leonard

In Part 1 of this series, you learned about the basic ROA concepts and how to create and implement an activable remote object. Part 2 will discuss advanced ROA techniques such as creating and registerting an activation group and initializing an activable object using the MarshalledObject class. In the end, you will see how to run an RMI application based on ROA.

Creating An Activation Group

An activation group is a group that contains activable remote objects. Actually, every activable remote object must belong to an activation group. When an activable remote object doesn't belong to a particular activation group, you must create a default one.

Activation groups tend to be used for organization tasks, but they can be used for other purposes. You can use activation groups to:

  • Monitor activable remote objects. For this task, every activation group has a monitor (the ActivationMonitor object. The activation group and the monitor have a permanent connection. The ActivationGroup informs the ActivationMonitor when an activable remote object becomes active or inactive. An activable remote object informs its ActivationGroup by calling the activeObject/inactiveObject methods. An ActivationGroup informs its ActivationMonitor by calling two similar methods. If the whole activation group is inactive, the ActivationMonitor calls the inactiveGroup method. In this case, the next call for an activable remote object, that belongs to that activation group, will create an activator to recreate the activation group.
  • Activate its activable remote objects. For this, the activator passes the activation identifier (ActivationID) and the activation descriptor (ActivationDesc) for the object that must be activated to the activation group.
  • Reactivate its activable remote objects.
Before create your own activation group, you must set a security manager. This task can be accomplished in different ways, but if you want to do this programmatically you can use the following example:
…
//setting a security manager 
Properties sys_prop=System.getProperties(); 
sys_prop.put("java.security.policy","12.policy");      
System.setSecurityManager(new RMISecurityManager());
…
The security constraints are in the 12.policy file, but you can define your own policy file.

There are different ways to create an activation group, but the most common way is to call the ActivationGroup.createGroup static method:

public static ActivationGroup createGroup
(ActivationGroupID id, ActivationGroupDesc desc, long incarnation) 
throws ActivationException
The last argument of this method specifies the number of "incarnations" for the activation group (default is 0) and is less important that the other two. The first two arguments are very important. As you can probably guess, the first argument, id, represents the group identifier which identifies a group in an unique way. Later, you will see how to obtain this argument. The second argument is an instance of the ActivationGroupDesc class and it represents the group descriptor. This descriptor contains important information for creating/recreating an activation group:
  • The name of the activation group class
  • The URL to activation group class
  • Information for activation group initialization
To create a group descriptor, you must create an instance of the ActivationGroupDesc. This class has two constructors:
  • public ActivationGroupDesc(Properties prop, ActivationGroupDesc.CommandEnvironment cmd): This constructor creates a group descriptor for the default activation group. It allows you to "override" either the default system properties (by using the prop argument) or the options used to run the JVM (by using the cmd argument).
  • public ActivationGroupDesc(String class, String source, MarshalledObject data, Properties prop, ActivationGroupDesc.CommandEnvironment cmd): When you define your own activation group, you must call this constructor for creating the group descriptor. The first three arguments of this constructor represent:
    • class: The name of the activation group class
    • source: The location form where this class can be loaded
    • data: Any information for activation group initialization
To obtain the activation group class name, you can call the ActivationGroupDesc.getClassName method. In fact, similar methods exist for all arguments of the ActivationGroupDesc constructor.

Remember, the activator is the "master" of the activation groups. It can recreate an activation group and can "offer" a JVM to an activation group.

When you write your own activation group class, it must meet the following requirements:

  • It must be a direct subclass of the ActivationGroup class.
  • It must have a public constructor that have the following two arguments:
    • An ActivationGroupID object: A group identifier
    • A MarshalledObject object: Information for activation group initialization

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs