Example usage for javax.xml.registry.infomodel RegistryObject getClass

List of usage examples for javax.xml.registry.infomodel RegistryObject getClass

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel RegistryObject getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:it.cnr.icar.eric.client.ui.common.ReferenceAssociation.java

String getJAXRName(RegistryObject ro) {
    String newClassName = ro.getClass().getName();
    newClassName = newClassName.substring(newClassName.lastIndexOf(".") + 1);

    if (newClassName.endsWith("Impl")) {
        //Remove Impl suffix for JAXR provider Impl classes
        newClassName = newClassName.substring(0, newClassName.length() - 4);
    }/*from  w  ww . j  av a2  s.  co m*/

    return newClassName;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

private void invokeMethodOnRegistryObject(String methodPrefix) throws NoSuchMethodException, Exception {
    RegistryObject drilldownRO = currentRegistryObject.getRegistryObject();
    Object currentRO = null;//www.  j a v  a  2 s.c om
    if (currentComposedRegistryObject.getNonRegistryObject() == null) {
        currentRO = currentComposedRegistryObject.getRegistryObject();
    } else {
        currentRO = currentComposedRegistryObject.getNonRegistryObject();
    }
    String objectType = currentRO.getClass().getName();
    Class<? extends RegistryObject> clazz = drilldownRO.getClass();
    Method m = null;
    String methodName = methodPrefix + objectType.substring(objectType.lastIndexOf(".") + 1);
    Class<?> argsClass[] = new Class[1];
    String argClassName = currentRO.getClass().getName();
    if (argClassName.endsWith("Impl")) {
        ClassLoader loader = drilldownRO.getClass().getClassLoader();
        int classNamelastIndex = argClassName.lastIndexOf(".") + 1;
        argClassName = argClassName.substring(classNamelastIndex);
        argClassName = argClassName.substring(0, argClassName.length() - 4);
        argsClass[0] = loader.loadClass("javax.xml.registry.infomodel." + argClassName);
        methodName = methodPrefix + argClassName;
        if ((currentRegistryObject.getObjectType().equalsIgnoreCase("ClassificationScheme")
                || currentRegistryObject.getObjectType().equalsIgnoreCase("ClassificationNode"))
                && methodName.equalsIgnoreCase("addConcept")) {
            methodName = "addChildConcept";
        }
        if ((currentRegistryObject.getObjectType().equalsIgnoreCase("ClassificationScheme")
                || currentRegistryObject.getObjectType().equalsIgnoreCase("ClassificationNode"))
                && methodName.equalsIgnoreCase("removeConcept")) {
            methodName = "removeChildConcept";
        }
        if (currentRegistryObject.getObjectType().equalsIgnoreCase("Organization")
                && methodName.equalsIgnoreCase("addOrganization")) {
            methodName = "addChildOrganization";
        }
        if (currentRegistryObject.getObjectType().equalsIgnoreCase("Organization")
                && methodName.equalsIgnoreCase("removeOrganization")) {
            methodName = "removeChildOrganization";
        }
    }
    try {
        m = clazz.getMethod(methodName, argsClass);
    } catch (NoSuchMethodException ex) {
        try {
            m = RegistryObjectImpl.class.getMethod(methodName, argsClass);
        } catch (NoSuchMethodException ex2) {
            try {
                m = IdentifiableImpl.class.getMethod(methodName, argsClass);
            } catch (NoSuchMethodException ex3) {
                try {
                    m = ExtensibleObjectImpl.class.getMethod(methodName, argsClass);
                } catch (NoSuchMethodException ex4) {
                    throw ex4;
                }
            }
        }
    }
    Object args[] = new Object[1];
    args[0] = currentRO;
    m.invoke(drilldownRO, args);
}

From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl.java

/**
 * Saves one or more Objects to the registry. An object may be a
 * RegistryObject  subclass instance. If an object is not in the registry,
 * it is created in the registry.  If it already exists in the registry
 * and has been modified, then its  state is updated (replaced) in the
 * registry/*from  w  w  w  .  j  a v  a2s .  c o  m*/
 * <p/>
 * TODO:Check if juddi can provide a facility to store a collection of heterogenous
 * objects
 * <p/>
 * TODO - does this belong here?  it's really an overload of
 * LifecycleManager.saveObjects, but all the help we need
 * like saveOrganization() is up here...
 *
 * @param col
 * @return a BulkResponse containing the Collection of keys for those objects
 *         that were saved successfully and any SaveException that was encountered
 *         in case of partial commit
 * @throws JAXRException
 */
public BulkResponse saveObjects(Collection col) throws JAXRException {

    Iterator iter = col.iterator();

    LinkedHashSet<Object> suc = new LinkedHashSet<Object>();
    Collection<Exception> exc = new ArrayList<Exception>();

    while (iter.hasNext()) {
        RegistryObject reg = (RegistryObject) iter.next();

        BulkResponse br = null;

        Collection<RegistryObject> c = new ArrayList<RegistryObject>();
        c.add(reg);

        if (reg instanceof javax.xml.registry.infomodel.Association) {
            br = saveAssociations(c, true);
        } else if (reg instanceof javax.xml.registry.infomodel.ClassificationScheme) {
            br = saveClassificationSchemes(c);
        } else if (reg instanceof javax.xml.registry.infomodel.Concept) {
            br = saveConcepts(c);
        } else if (reg instanceof javax.xml.registry.infomodel.Organization) {
            br = saveOrganizations(c);
        } else if (reg instanceof javax.xml.registry.infomodel.Service) {
            br = saveServices(c);
        } else if (reg instanceof javax.xml.registry.infomodel.ServiceBinding) {
            br = saveServiceBindings(c);
        } else {
            throw new JAXRException("Delete Operation for " + reg.getClass() + " not implemented by Scout");
        }

        if (br.getCollection() != null) {
            suc.addAll(br.getCollection());
        }

        if (br.getExceptions() != null) {
            exc.addAll(br.getExceptions());
        }
    }

    BulkResponseImpl bulk = new BulkResponseImpl();

    /*
     *  TODO - what is the right status?
     */
    bulk.setStatus(JAXRResponse.STATUS_SUCCESS);

    bulk.setCollection(suc);
    bulk.setExceptions(exc);

    return bulk;
}