Search in sources :

Example 1 with AcsJJavaAnyEx

use of alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx in project ACS by ACS-Community.

the class AnyAide method internalArrayToCorbaAny.

/**
	 * Moved here from method arrayToCorbaAny (deleted in ACS 9.0).
	 */
protected Any internalArrayToCorbaAny(Object objs) throws AcsJException {
    // class object for the array
    Class cl = objs.getClass();
    if (!cl.isArray()) {
        Throwable cause = new Throwable("Object of type " + cl.getName() + " is not an array.");
        throw new AcsJJavaAnyEx(cause);
    }
    // class object for the array elements
    Class objClass = cl.getComponentType();
    int length = Array.getLength(objs);
    // doubleSeq
    if (objClass.equals(double.class)) {
        double[] values = new double[length];
        System.arraycopy(objs, 0, values, 0, length);
        return doubleArrayToCorbaAny(values);
    } else // longSeq
    if (objClass.equals(int.class)) {
        int[] values = new int[length];
        System.arraycopy(objs, 0, values, 0, length);
        return intArrayToCorbaAny(values);
    } else // stringSeq
    if (objClass.equals(String.class)) {
        String[] values = new String[length];
        System.arraycopy(objs, 0, values, 0, length);
        return stringArrayToCorbaAny(values);
    } else // floatSeq
    if (objClass.equals(float.class)) {
        float[] values = new float[length];
        System.arraycopy(objs, 0, values, 0, length);
        return floatArrayToCorbaAny(values);
    } else {
        // if we do not know what it is, there's not much we can
        // do.
        Throwable cause = new Throwable(cl.getName() + " not supported!");
        throw new AcsJJavaAnyEx(cause);
    }
}
Also used : AcsJJavaAnyEx(alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx)

Example 2 with AcsJJavaAnyEx

use of alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx in project ACS by ACS-Community.

the class Consumer method removeSubscription.

/**
	 * Remove a subscription from this consumer. After invoking this, events of
	 * the parameter's type will no longer be received.
	 * 
	 * @param structClassName
	 *           Unsubscribes from this IDL struct (Java class). By passing in
	 *           null here, no events of any type will be received.
	 * @throws AcsJException
	 *            Thrown if there is some CORBA problem (like this consumer has
	 *            never subscribed to the IDL struct).
	 */
public void removeSubscription(Class structClass) throws AcsJException {
    String type = "*";
    String domain = "*";
    // If the developer is not unsubscribing from everything...
    if (structClass != null) {
        // get the type/domain to unsubscribe from
        type = structClass.getName().substring(structClass.getName().lastIndexOf('.') + 1);
        domain = getChannelDomain();
        // Remove the handler function if there is one...
        synchronized (m_handlerFunctions) {
            if (m_handlerFunctions.containsKey(structClass.getName())) {
                // remove the subscription from the hash
                m_handlerFunctions.remove(structClass.getName());
            } else {
                throw new AcsJJavaAnyEx("Unsubscribing from '" + structClass.getName() + "' type of event when not actually subscribed to this type.");
            }
        }
    } else // they're removing all subscriptions so let's clear the hash
    {
        m_handlerFunctions.clear();
    }
    try {
        // Unsubscribe to events
        EventType[] added = {};
        EventType[] removed = { new EventType(domain, type) };
        // really unsubscribe from events
        m_consumerAdmin.subscription_change(added, removed);
    } catch (org.omg.CosNotifyComm.InvalidEventType e) {
        String msg = "'" + type + "' event type is invalid for the '" + m_channelName + "' channel: ";
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(msg + e.getMessage());
    }
}
Also used : AcsJJavaAnyEx(alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx) EventType(org.omg.CosNotification.EventType) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)

Aggregations

AcsJJavaAnyEx (alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx)2 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)1 EventType (org.omg.CosNotification.EventType)1