/// <summary> /// Create and set the activation group for the current VM. The /// activation group can only be set if it is not currently set. /// An activation group is set using the <code>createGroup</code> /// method when the <code>Activator</code> initiates the /// re-creation of an activation group in order to carry out /// incoming <code>activate</code> requests. A group must first be /// registered with the <code>ActivationSystem</code> before it can /// be created via this method. /// /// <para>The group class specified by the /// <code>ActivationGroupDesc</code> must be a concrete subclass of /// <code>ActivationGroup</code> and have a public constructor that /// takes two arguments: the <code>ActivationGroupID</code> for the /// group and the <code>MarshalledObject</code> containing the /// group's initialization data (obtained from the /// <code>ActivationGroupDesc</code>. /// /// </para> /// <para>If the group class name specified in the /// <code>ActivationGroupDesc</code> is <code>null</code>, then /// this method will behave as if the group descriptor contained /// the name of the default activation group implementation class. /// /// </para> /// <para>Note that if your application creates its own custom /// activation group, a security manager must be set for that /// group. Otherwise objects cannot be activated in the group. /// <seealso cref="SecurityManager"/> is set by default. /// /// </para> /// <para>If a security manager is already set in the group VM, this /// method first calls the security manager's /// <code>checkSetFactory</code> method. This could result in a /// <code>SecurityException</code>. If your application needs to /// set a different security manager, you must ensure that the /// policy file specified by the group's /// <code>ActivationGroupDesc</code> grants the group the necessary /// permissions to set a new security manager. (Note: This will be /// necessary if your group downloads and sets a security manager). /// /// </para> /// <para>After the group is created, the /// <code>ActivationSystem</code> is informed that the group is /// active by calling the <code>activeGroup</code> method which /// returns the <code>ActivationMonitor</code> for the group. The /// application need not call <code>activeGroup</code> /// independently since it is taken care of by this method. /// /// </para> /// <para>Once a group is created, subsequent calls to the /// <code>currentGroupID</code> method will return the identifier /// for this group until the group becomes inactive. /// /// </para> /// </summary> /// <param name="id"> the activation group's identifier </param> /// <param name="desc"> the activation group's descriptor </param> /// <param name="incarnation"> the group's incarnation number (zero on group's /// initial creation) </param> /// <returns> the activation group for the VM </returns> /// <exception cref="ActivationException"> if group already exists or if error /// occurs during group creation </exception> /// <exception cref="SecurityException"> if permission to create group is denied. /// (Note: The default implementation of the security manager /// <code>checkSetFactory</code> /// method requires the RuntimePermission "setFactory") </exception> /// <exception cref="UnsupportedOperationException"> if and only if activation is /// not supported by this implementation </exception> /// <seealso cref= SecurityManager#checkSetFactory /// @since 1.2 </seealso> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static synchronized ActivationGroup createGroup(ActivationGroupID id, final ActivationGroupDesc desc, long incarnation) throws ActivationException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: public static ActivationGroup CreateGroup(ActivationGroupID id, ActivationGroupDesc desc, long incarnation) { lock (typeof(ActivationGroup)) { SecurityManager security = System.SecurityManager; if (security != null) { security.CheckSetFactory(); } if (CurrGroup != null) { throw new ActivationException("group already exists"); } if (CanCreate == false) { throw new ActivationException("group deactivated and " + "cannot be recreated"); } try { // load group's class String groupClassName = desc.ClassName; Class cl; Class defaultGroupClass = typeof(sun.rmi.server.ActivationGroupImpl); if (groupClassName == null || groupClassName.Equals(defaultGroupClass.Name)) // see 4252236 { cl = defaultGroupClass; } else { Class cl0; try { cl0 = RMIClassLoader.LoadClass(desc.Location, groupClassName); } catch (Exception ex) { throw new ActivationException("Could not load group implementation class", ex); } if (cl0.IsSubclassOf(typeof(ActivationGroup))) { cl = cl0.AsSubclass(typeof(ActivationGroup)); } else { throw new ActivationException("group not correct class: " + cl0.Name); } } // create group //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: Constructor<? extends ActivationGroup> constructor = cl.getConstructor(ActivationGroupID.class, java.rmi.MarshalledObject.class); Constructor <?> constructor = cl.getConstructor(typeof(ActivationGroupID), typeof(MarshalledObject)); ActivationGroup newGroup = constructor.newInstance(id, desc.Data); CurrSystem = id.System; newGroup.Incarnation = incarnation; newGroup.Monitor_Renamed = CurrSystem.ActiveGroup(id, newGroup, incarnation); CurrGroup = newGroup; CurrGroupID = id; CanCreate = false; } catch (InvocationTargetException e) { e.TargetException.printStackTrace(); throw new ActivationException("exception in group constructor", e.TargetException); } catch (ActivationException e) { throw e; } catch (Exception e) { throw new ActivationException("exception creating group", e); } return(CurrGroup); } }
/// <summary> /// Constructs a unique group id. /// </summary> /// <param name="system"> the group's activation system </param> /// <exception cref="UnsupportedOperationException"> if and only if activation is /// not supported by this implementation /// @since 1.2 </exception> public ActivationGroupID(ActivationSystem system) { this.System_Renamed = system; }