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.

 Internet.com eBook Library
 IBM Software Construction Toolbox
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 38
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%.

Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel
Jim Zemlin: The New Center of Linux Gravity
Microsoft's Novell Investment Tops $340M
Fedora 10 Takes Shape
IBM Gives a Mobile Voice to Developers
Inadequate Tools Send Software Down the Drain
USB 3.0 One Step Closer to Reality
Would-Be Linux Contributors May Get a Leg Up

Book Excerpt: Microsoft Expression Blend Unleashed
Develop a Mobile RSS Feed the Easy Way
State of the Semantic Web: Know Where to Look
A 3D Exploration of the HTML Canvas Element
Setting Up and Running Subversion and Tortoise SVN with Visual Studio and .NET
Java/JRuby Developers, Say Open 'Sesame' to the Semantic Web
Interpreting Images with MRDS Services
DevXtra Editors' Blog: Executives Avoiding Cloud Computing in Droves
Q&A with James Reinders on the Intel Parallel Studio Beta Program
The Pros and Cons of Outsourcing Enterprise Emails

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