[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: Changes is org.omg policy helper and implementation ba
From: |
Meskauskas Audrius |
Subject: |
[cp-patches] FYI: Changes is org.omg policy helper and implementation base. |
Date: |
Sat, 02 Jul 2005 23:53:41 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Policies were defined in the earlier versions, but they are actually
used since jdk 1.4 only. To proceed with them, I need the adaptations below.
2005-06-02 Audrius Meskauskas, <address@hidden>
* gnu/CORBA/_PolicyImplBase.java: Ihnerit from Policy.
(ids): Made final non static, new constructor.
(type, value, policyCode): New fields.
(_invoke): Handle "value" operation.
(getValue, getCode, destroy, toString, copy, equals, hashCode):
New methods.
* org/omg/CORBA/PolicyHelper.java (narrow): Removed check for
repository for repository id.
Index: gnu/CORBA/_PolicyImplBase.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/_PolicyImplBase.java,v
retrieving revision 1.2
diff -u -r1.2 _PolicyImplBase.java
--- gnu/CORBA/_PolicyImplBase.java 2 Jul 2005 20:32:09 -0000 1.2
+++ gnu/CORBA/_PolicyImplBase.java 2 Jul 2005 21:43:28 -0000
@@ -40,8 +40,8 @@
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.Policy;
import org.omg.CORBA.PolicyHelper;
-import org.omg.CORBA.PolicyOperations;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.ObjectImpl;
@@ -49,7 +49,7 @@
import org.omg.CORBA.portable.ResponseHandler;
/**
- * The server side implementatin base for the address@hidden Policy}.
+ * The server side implementation base for the address@hidden Policy}.
*
* @specnote The java 1.4 API does not define the server side policy
* implementation base, but it defines the policy client side stub.
@@ -61,7 +61,7 @@
*/
public abstract class _PolicyImplBase
extends ObjectImpl
- implements PolicyOperations, InvokeHandler
+ implements Policy, InvokeHandler
{
/**
* Use serialVersionUID for interoperability.
@@ -69,14 +69,60 @@
private static final long serialVersionUID = 1;
/**
- * The binding interator repository ids.
+ * The policy repository ids.
*/
- private static String[] ids = { PolicyHelper.id() };
+ private final String[] ids;
+
+ /**
+ * The type of this policy.
+ */
+ private final int type;
+
+ /**
+ * The value of this policy. The value object is never the same
+ * for different policies.
+ */
+ private final java.lang.Object value;
+
+ /**
+ * The policy integer code, written in request to write
+ * the policy value.
+ */
+ private final int policyCode;
+
+ /**
+ * Create the new policy of the given type, having the given value.
+ * For security reasons, the method is kept package private.
+ *
+ * @param p_type the type of this policy.
+ * @param p_value the value of this policy.
+ * @param p_code the integer code of this policy.
+ * @param p_idl the policy IDL type string. The address@hidden #_ids()}
+ * will return array, first line being this string and another
+ * being PolicyHelper.id().
+ */
+ public _PolicyImplBase(int p_type, java.lang.Object p_value, int p_code,
+ String p_idl
+ )
+ {
+ type = p_type;
+ value = p_value;
+ policyCode = p_code;
+ ids = new String[] { p_idl, PolicyHelper.id() };
+ }
+
+ /**
+ * Get the integer code of the type of this policy.
+ */
+ public final int policy_type()
+ {
+ return type;
+ }
/**
* Return the list of repository ids.
*/
- public String[] _ids()
+ public final String[] _ids()
{
return ids;
}
@@ -84,9 +130,9 @@
/**
* Call the required method.
*/
- public OutputStream _invoke(String method, InputStream input,
- ResponseHandler rh
- )
+ public final OutputStream _invoke(String method, InputStream input,
+ ResponseHandler rh
+ )
{
OutputStream output = null;
@@ -101,7 +147,7 @@
// The "copy" has been invoked.
org.omg.CORBA.Object returns = copy();
output = rh.createReply();
- output.write_Object(returns);
+ output.write_Object(this);
}
else if (method.equals("policy_type"))
{
@@ -110,9 +156,76 @@
output = rh.createReply();
output.write_long(returns);
}
+ else if (method.equals("value"))
+ {
+ // The "value" can be invoked on the children types
+ // and must return an integer, representing the policy value
+ // (CORBA enumeration).
+ output = rh.createReply();
+ output.write_long(policyCode);
+ }
else
throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
return output;
}
+
+ /**
+ * Get the value of this policy
+ */
+ public final java.lang.Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Get the integer code of this policy value.
+ */
+ public final int getCode()
+ {
+ return policyCode;
+ }
+
+ /**
+ * Returns without action. It is a work of garbage collector
+ * to remove the unused objects.
+ */
+ public final void destroy()
+ {
+ }
+
+ /**
+ * Returns the string representation of the given policy.
+ */
+ public final String toString()
+ {
+ return value.toString();
+ }
+
+ /**
+ * Create a copy of this policy. The object is not mutable, so
+ * <code>this</code> can be returned.
+ *
+ * @return <code>this</code>
+ */
+ public Policy copy()
+ {
+ return this;
+ }
+
+ /**
+ * Use the value to get a hash code.
+ */
+ public int hashCode()
+ {
+ return getValue().hashCode();
+ }
+
+ /**
+ * Check the values for equality.
+ */
+ public boolean equals(Object x)
+ {
+ return x == null ? false : getValue().equals(x);
+ }
}
\ No newline at end of file
Index: org/omg/CORBA/PolicyHelper.java
===================================================================
RCS file: /cvsroot/classpath/classpath/org/omg/CORBA/PolicyHelper.java,v
retrieving revision 1.2
diff -u -r1.2 PolicyHelper.java
--- org/omg/CORBA/PolicyHelper.java 2 Jul 2005 20:32:57 -0000 1.2
+++ org/omg/CORBA/PolicyHelper.java 2 Jul 2005 21:41:50 -0000
@@ -130,10 +130,12 @@
return null;
else if (obj instanceof Policy)
return (Policy) obj;
- else if (!obj._is_a(id()))
- throw new BAD_PARAM("Not a Policy");
else
{
+ // Check for the policy id cannot be performed because
+ // this helper must read various subclasses of the Policy,
+ // and the IOR profile currently supports only one id.
+
Delegate delegate = ((ObjectImpl) obj)._get_delegate();
return new _PolicyStub(delegate);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: Changes is org.omg policy helper and implementation base.,
Meskauskas Audrius <=