コード例 #1
0
  public XMLSessionConfigProject_11_1_1() {
    super();
    addDescriptor(buildOc4jJGroupsTransportManagerConfigDescriptor());
    addDescriptor(buildServerPlatformConfigDescriptorFor(Oc4jPlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(GlassfishPlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(SunAS9PlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(WebLogic_9_PlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(WebLogic_10_PlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(WebSphere_6_1_PlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(WebSphere_7_0_PlatformConfig.class));
    addDescriptor(buildServerPlatformConfigDescriptorFor(WebSphere_Liberty_Platform_Config.class));

    // 242452 -- add metadata support for XMLLogin's DocumentPreservationPolicy
    addDescriptor(buildDocumentPreservationPolicyConfigDescriptor());
    addDescriptor(buildDescriptorLevelDocumentPreservationPolicyConfigDescriptor());
    addDescriptor(buildNoDocumentPreservationPolicyConfigDescriptor());
    addDescriptor(buildXMLBinderPolicyConfigDescriptor());
    addDescriptor(buildNodeOrderingPolicyConfigDescriptor());
    addDescriptor(buildAppendNewElementsOrderingPolicyConfigDescriptor());
    addDescriptor(buildIgnoreNewElementsOrderingPolicyConfigDescriptor());
    addDescriptor(buildRelativePositionOrderingPolicyConfigDescriptor());

    // Set the namespaces on all descriptors.
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put("xsi", W3C_XML_SCHEMA_INSTANCE_NS_URI);
    namespaceResolver.put("xsd", W3C_XML_SCHEMA_NS_URI);

    for (Iterator descriptors = getDescriptors().values().iterator(); descriptors.hasNext(); ) {
      XMLDescriptor descriptor = (XMLDescriptor) descriptors.next();
      descriptor.setNamespaceResolver(namespaceResolver);
    }
  }
コード例 #2
0
 @Override
 public void handleSqlTableType(String tableTypeName, String targetTypeName) {
   // trim-off dotted-prefix, toLowerCase
   String tableTypeNameAlias = trimDotPrefix(tableTypeName).toLowerCase();
   String userType = nct.generateSchemaAlias(tableTypeNameAlias);
   XMLDescriptor xdesc = descriptorMap.get(tableTypeNameAlias);
   if (xdesc == null) {
     xdesc = new XMLDescriptor();
     xdesc.setAlias(tableTypeNameAlias);
     xdesc.setJavaClassName(
         packageName.toLowerCase() + "." + tableTypeNameAlias + COLLECTION_WRAPPER_SUFFIX);
     xdesc.getQueryManager();
     XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
     schemaReference.setSchemaContext("/" + userType);
     schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
     xdesc.setSchemaReference(schemaReference);
     NamespaceResolver nr = new NamespaceResolver();
     nr.setDefaultNamespaceURI(targetNamespace);
     xdesc.setNamespaceResolver(nr);
     descriptorMap.put(tableTypeNameAlias, xdesc);
   }
   // before we push the new SqlArrayTypeHelper, check stac to see if we are part
   // of nested chain of object types
   if (!stac.isEmpty()) {
     ListenerHelper listenerHelper = stac.peek();
     if (listenerHelper.isReturnArg()) {
       xdesc.setDefaultRootElement(userType);
     }
   }
   stac.push(new SqlArrayTypeHelper(tableTypeNameAlias, targetTypeName));
 }
コード例 #3
0
  /** INTERNAL: Get the XMLDescriptor associated with this Type or generate a new one. */
  public void initializeNamespaces(List namespaceResolvers) {
    if (!isDataType()) {
      NamespaceResolver nr = new NamespaceResolver();

      // copy namespaces between resolvers for well known and SDO namespaces
      if (namespaceResolvers != null) {
        for (int i = 0; i < namespaceResolvers.size(); i++) {
          NamespaceResolver nextNR = (NamespaceResolver) namespaceResolvers.get(i);
          if (nextNR != null) {
            for (int j = 0, size = nextNR.getNamespaces().size(); j < size; j++) {
              Namespace nextNamespace = (Namespace) nextNR.getNamespaces().get(j);
              if ((!nextNamespace.getPrefix().equals(XMLConstants.XMLNS))
                  && (!nextNamespace.getNamespaceURI().equals(XMLConstants.SCHEMA_URL))
                  && (!nextNamespace.getNamespaceURI().equals(SDOConstants.SDOJAVA_URL))
                  && (!nextNamespace.getNamespaceURI().equals(SDOConstants.SDOXML_URL))
                  && (!nextNamespace.getNamespaceURI().equals(SDOConstants.SDO_URL))) {
                String newPrefix =
                    ((SDOTypeHelper) aHelperContext.getTypeHelper())
                        .addNamespace(nextNamespace.getPrefix(), nextNamespace.getNamespaceURI());
                nr.put(newPrefix, nextNamespace.getNamespaceURI());
              }
            }
          }
        }
      }
      xmlDescriptor.setNamespaceResolver(nr);
      if (getURI() != null) {
        String prefix = ((SDOTypeHelper) aHelperContext.getTypeHelper()).getPrefix(getURI());
        xmlDescriptor.getNamespaceResolver().put(prefix, getURI());
      }
      xmlDescriptor
          .getNamespaceResolver()
          .put(XMLConstants.SCHEMA_INSTANCE_PREFIX, XMLConstants.SCHEMA_INSTANCE_URL);
    }
  }
  protected XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = super.getEmployeeDescriptor();
    descriptor.setDefaultRootElement("thens:employee");

    NamespaceResolver resolver = new NamespaceResolver();
    resolver.put("thensdiff", "www.example.com/some-dir/employee.xsd");
    descriptor.setNamespaceResolver(resolver);

    return descriptor;
  }
コード例 #5
0
  private XMLDescriptor getAddressDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Address.class);

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "urn:example");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setXPath("text()");
    xmlDescriptor.addMapping(streetMapping);

    return xmlDescriptor;
  }
コード例 #6
0
  private XMLDescriptor getCustomerDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Customer.class);
    xmlDescriptor.setDefaultRootElement("ns:customer");

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "urn:example");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setXPath("//ns:customer/ns:phone-number/preceding-sibling::*[1]");
    addressMapping.setReferenceClass(Address.class);
    xmlDescriptor.addMapping(addressMapping);

    return xmlDescriptor;
  }
  public ClassDescriptor buildWrapperDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Wrapper.class);
    descriptor.setDefaultRootElement("myns:wrapper");

    XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
    mapping.setReferenceClass(Root.class);
    mapping.setAttributeName("theRoot");
    mapping.setXPath("myns:root");
    descriptor.addMapping(mapping);

    NamespaceResolver nr = new NamespaceResolver();
    nr.put("myns", "www.example.com/some-dir/some.xsd");
    nr.put("ns0", "www.example.com/test.xsd");
    descriptor.setNamespaceResolver(nr);

    return descriptor;
  }
  public ClassDescriptor buildRootDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Root.class);
    descriptor.setDefaultRootElement("myns:root");

    XMLAnyAttributeMapping mapping = new XMLAnyAttributeMapping();
    mapping.setAttributeName("any");
    mapping.setGetMethodName("getAny");
    mapping.setSetMethodName("setAny");
    descriptor.addMapping(mapping);

    NamespaceResolver nr = new NamespaceResolver();
    nr.put("myns", "www.example.com/some-dir/some.xsd");
    // nr.put("", "www.example.com/some-other-dir/some.xsd");
    descriptor.setNamespaceResolver(nr);

    return descriptor;
  }
  public DirectIsSetNodeNullPolicyTrueTestCases(String name) throws Exception {
    super(name);
    setControlDocument(XML_RESOURCE);

    AbstractNullPolicy aNullPolicy = new IsSetNullPolicy();
    // alter unmarshal policy state
    aNullPolicy.setNullRepresentedByEmptyNode(true); // no effect
    aNullPolicy.setNullRepresentedByXsiNil(false); // no effect
    // alter marshal policy state
    aNullPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.XSI_NIL); // .EMPTY_NODE);
    ((IsSetNullPolicy) aNullPolicy).setIsSetMethodName("isSetFirstName");
    Project aProject = new DirectNodeNullPolicyProject(true);
    XMLDescriptor employeeDescriptor = (XMLDescriptor) aProject.getDescriptor(Employee.class);
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, XMLConstants.SCHEMA_INSTANCE_URL);
    employeeDescriptor.setNamespaceResolver(namespaceResolver);
    XMLDirectMapping aMapping =
        (XMLDirectMapping) employeeDescriptor.getMappingForAttributeName("firstName");
    aMapping.setNullPolicy(aNullPolicy);
    setProject(aProject);
  }
コード例 #10
0
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(
        org.eclipse.persistence.testing.oxm.mappings.transformation.Employee.class);
    xmlDescriptor.setDefaultRootElement("ns:root");

    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    URL url = ClassLoader.getSystemResource(XML_SCHEMA_RESOURCE);
    schemaReference.setURL(url);
    xmlDescriptor.setSchemaReference(schemaReference);

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "ElemDecl/maxOccurs");
    nsResolver.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("ns:Local");
    xmlDescriptor.addMapping(nameMapping);

    return xmlDescriptor;
  }
コード例 #11
0
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Employee.class);
    xmlDescriptor.setDefaultRootElement("DEFAULT:employee");

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("DEFAULT", "http://www.example.com/EMPLOYEE");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    // Unqualified attributes are in the null namespace
    // rather than the default namespace
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("DEFAULT:personal-info/@id");
    xmlDescriptor.addMapping(idMapping);

    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("DEFAULT:personal-info/DEFAULT:name/text()");
    xmlDescriptor.addMapping(nameMapping);

    return xmlDescriptor;
  }
コード例 #12
0
 @Override
 public void handleObjectType(String objectTypeName, String targetTypeName, int numAttributes) {
   // JDBC Advanced type?
   if (numAttributes > 0) {
     // trim-off dotted-prefix, toLowerCase
     String objectTypeNameAlias = trimDotPrefix(objectTypeName).toLowerCase();
     XMLDescriptor xdesc = descriptorMap.get(objectTypeNameAlias);
     String userType = nct.generateSchemaAlias(objectTypeNameAlias);
     if (xdesc == null) {
       xdesc = new XMLDescriptor();
       xdesc.setAlias(objectTypeNameAlias);
       xdesc.setJavaClassName(packageName.toLowerCase() + "." + objectTypeNameAlias);
       xdesc.getQueryManager();
       XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
       schemaReference.setSchemaContext("/" + userType);
       schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
       xdesc.setSchemaReference(schemaReference);
       NamespaceResolver nr = new NamespaceResolver();
       nr.setDefaultNamespaceURI(targetNamespace);
       xdesc.setNamespaceResolver(nr);
       descriptorMap.put(objectTypeNameAlias, xdesc);
     }
     // before we push the new ObjectTypeHelper, check stac to see if we are part
     // of nested chain of object types
     if (!stac.isEmpty()) {
       ListenerHelper listenerHelper = stac.peek();
       if (listenerHelper.isAttribute()) {
         AttributeFieldHelper fieldHelper = (AttributeFieldHelper) stac.pop();
         fieldHelper.setSqlTypeName(objectTypeNameAlias);
         String fieldName = fieldHelper.attributeFieldName();
         String attributeName = fieldName.toLowerCase();
         ListenerHelper listenerHelper2 = stac.peek();
         if (listenerHelper2.isObject()) {
           ObjectTypeHelper objectTypeHelper2 = (ObjectTypeHelper) listenerHelper2;
           String objectTypeNameAlias2 = objectTypeHelper2.objectTypename();
           XMLDescriptor xdesc2 = descriptorMap.get(objectTypeNameAlias2);
           if (xdesc2 != null) {
             DatabaseMapping dm = xdesc2.getMappingForAttributeName(attributeName);
             if (dm == null) {
               XMLCompositeObjectMapping compMapping = new XMLCompositeObjectMapping();
               compMapping.setAttributeName(attributeName);
               compMapping.setReferenceClassName(xdesc.getJavaClassName());
               compMapping.setXPath(attributeName);
               XMLField xField = (XMLField) compMapping.getField();
               xField.setRequired(true);
               xdesc2.addMapping(compMapping);
             }
             // last attribute, pop ObjectTypeHelper off stack
             int numAttributes2 = objectTypeHelper2.decrNumAttributes();
             if (numAttributes2 == 0) {
               stac.pop();
             }
           }
         }
       } else if (listenerHelper.isArray()) {
         SqlArrayTypeHelper sqlArrayTypeHelper = (SqlArrayTypeHelper) stac.pop();
         String sqlArrayTypeAlias = sqlArrayTypeHelper.arrayTypename();
         XMLDescriptor xdesc2 = descriptorMap.get(sqlArrayTypeAlias);
         if (xdesc2 != null) {
           boolean itemsMappingFound =
               xdesc2.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME) == null
                   ? false
                   : true;
           if (!itemsMappingFound) {
             XMLCompositeCollectionMapping itemsMapping = new XMLCompositeCollectionMapping();
             itemsMapping.setAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
             itemsMapping.setXPath(ITEM_MAPPING_NAME);
             itemsMapping.useCollectionClassName("java.util.ArrayList");
             itemsMapping.setReferenceClassName(xdesc.getJavaClassName());
             xdesc2.addMapping(itemsMapping);
           }
         }
       } else if (listenerHelper.isReturnArg()) {
         // ReturnArgHelper returnArgHelper = (ReturnArgHelper)stac.pop();
         stac.pop();
         xdesc.setDefaultRootElement(userType);
       }
     }
     stac.push(new ObjectTypeHelper(objectTypeNameAlias, targetTypeName, numAttributes));
   }
 }
コード例 #13
0
 protected void setNamespaceResolverOnDescriptors() {
   for (Iterator descriptors = getDescriptors().values().iterator(); descriptors.hasNext(); ) {
     XMLDescriptor descriptor = (XMLDescriptor) descriptors.next();
     descriptor.setNamespaceResolver(ns);
   }
 }