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.

 DevX Skillbuilding from IBM developerWorks
 RIA Run Contest: Build Next-Gen Apps in Microsoft Silverlight 2
 Avaya DevConnect Center
 Intel Go Parallel Portal
 Internet.com eBook Library
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 53
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%.

SaaS Tool Offers Custom Database Development
Microsoft’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear
Red Hat Heads For The JON 2.0
Out with the Old, in with the New at JavaOne
Trolltech Expands WebKit Footprint
Oracle: Eating its Own Open Source Food
Big Money and Open Source May Not Compute
Open Source Embrace Gives Sun New Fans
NetBeans, OpenSolaris Also in Spotlight at JavaOne

Clean Up Function Syntax Mess with decltype
Sutter Speaks: The Future of Concurrency
INTEL SCAVENGER HUNT, LENOVO X300 AND APPLE IPOD TOUCH GIVEAWAY (the "Giveaway")
Comparing Multi-Core Processors for Server Virtualization
Intel® Desktop Business Computing Solutions
Intel: What Downturn?
Managing the Evolving Data Center
Implement Drag and Drop in Your Windows Forms Applications
Processing Linked Web Data with XSLT
New Platform Security Tweaks Nokia's Python for S60 Application Development

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



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES