aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIaroslav Savytskyi2014-07-30 05:30:38 (EDT)
committerMartin Vojtek2014-08-19 11:06:22 (EDT)
commit3211a448b374a8f2cf873268eca68e833dc05c4e (patch)
tree3e33107128e5ac8f9a59d9abe383b1db46736577
parent321d1b63e1ef4f0a5e5f24f71f312bbf6e96d8bc (diff)
downloadeclipselink.runtime-3211a448b374a8f2cf873268eca68e833dc05c4e.zip
eclipselink.runtime-3211a448b374a8f2cf873268eca68e833dc05c4e.tar.gz
eclipselink.runtime-3211a448b374a8f2cf873268eca68e833dc05c4e.tar.bz2
Add logging.
- Bug # 441720 - remove synchronization block - create startup context listener Signed-off-by: Iaroslav Savytskyi <iaroslav.savytskyi@oracle.com>
-rw-r--r--sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceClientTestCases.java77
-rw-r--r--sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceImpl.java94
-rw-r--r--sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceInitException.java23
-rw-r--r--sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/InitSingleton.java49
-rw-r--r--sdo/org.eclipse.persistence.sdo/src/org/eclipse/persistence/sdo/helper/delegates/SDOTypeHelperDelegate.java292
5 files changed, 317 insertions, 218 deletions
diff --git a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceClientTestCases.java b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceClientTestCases.java
index c7f0279..a99540d 100644
--- a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceClientTestCases.java
+++ b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceClientTestCases.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -14,22 +14,26 @@ package org.eclipse.persistence.testing.sdo.server;
import commonj.sdo.helper.HelperContext;
import commonj.sdo.impl.HelperProvider;
-
-import java.io.FileInputStream;
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
+
+import java.io.FileInputStream;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.eclipse.persistence.sdo.helper.SDOXSDHelper;
-import junit.framework.TestCase;
-
-public class DeptServiceClientTestCases extends TestCase {
- public String initialContextFactory;
- public String securityPrincipal;
- public String securityCredentials;
+import junit.framework.TestCase;
+
+public class DeptServiceClientTestCases extends TestCase {
+
+ private static final Logger LOGGER = Logger.getLogger(DeptServiceClientTestCases.class.getName());
+
+ public String initialContextFactory;
+ public String securityPrincipal;
+ public String securityCredentials;
public String providerUrl;
public String sessionBean;
@@ -40,12 +44,13 @@ public class DeptServiceClientTestCases extends TestCase {
securityCredentials = System.getProperty("securityCredentials");
providerUrl = System.getProperty("providerUrl");
sessionBean = System.getProperty("sessionBean");
- }
-
- public void testDepartmentService() {
- DeptService svc = null;
- try {
- Context ctx = getInitialContext();
+ }
+
+ public void testDepartmentService() {
+ LOGGER.info("********** testDepartmentService() called **********");
+ DeptService svc = null;
+ try {
+ Context ctx = getInitialContext();
svc = (DeptService) ctx.lookup(sessionBean);
} catch (NamingException e) {
fail("DeptService lookup failed: " + e);
@@ -59,12 +64,13 @@ public class DeptServiceClientTestCases extends TestCase {
dept.setDname(dept.getDname() + "'");
dept.setLoc(dept.getLoc() + "'");
assertTrue("Department [30] update was unsuccessful.", svc.updateDept(dept));
- }
-
- private Context getInitialContext() {
- Hashtable<String, String> env = new Hashtable<String, String>();
- try {
- env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
+ }
+
+ private Context getInitialContext() {
+ LOGGER.info("********** getInitialContext() called **********");
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ try {
+ env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
env.put(Context.SECURITY_PRINCIPAL, securityPrincipal);
env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
env.put(Context.PROVIDER_URL, providerUrl);
@@ -79,12 +85,13 @@ public class DeptServiceClientTestCases extends TestCase {
"]: " + x);
}
return null;
- }
-
- private void defineXSD() {
- try {
- FileInputStream is = new FileInputStream(getSchemaName());
- HelperContext ctx = HelperProvider.getDefaultContext();
+ }
+
+ private void defineXSD() {
+ LOGGER.info("********** defineXSD() called **********");
+ try {
+ FileInputStream is = new FileInputStream(getSchemaName());
+ HelperContext ctx = HelperProvider.getDefaultContext();
SDOXSDHelper helper = (SDOXSDHelper) ctx.getXSDHelper();
helper.define(is, null);
} catch (Exception ioe) {
diff --git a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceImpl.java b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceImpl.java
index e5eed1c..9292c27 100644
--- a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceImpl.java
+++ b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceImpl.java
@@ -1,67 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* etang - April 12/2010 - 2.1 - Initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.testing.sdo.server;
-
-import java.net.URL;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
+ ******************************************************************************/
+package org.eclipse.persistence.testing.sdo.server;
+
+import java.util.logging.Logger;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
import org.eclipse.persistence.sdo.helper.SDOHelperContext;
-@Stateless(name = "org.eclipse.persistence.testing.sdo.server.DeptServiceBean", mappedName = "DeptServiceBean")
-@Remote
-public class DeptServiceImpl implements DeptService {
- private static boolean _isInited = false;
-
- public DeptServiceImpl() {
- init();
- }
-
- protected void init() {
- if (_isInited) {
- return;
- }
- synchronized (DeptServiceImpl.class) {
- if (_isInited) {
- return;
- }
- try {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- URL url = cl.getResource("org/eclipse/persistence/testing/sdo/server/Dept.xsd");
- String path = url.toExternalForm();
- SDOHelperContext.getHelperContext().getXSDHelper().define(url.openStream(), path.substring(0, path.lastIndexOf('/') + 1));
- _isInited = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
-
- public Dept getDept(Integer deptno) {
- System.out.println("\n********** getDept() Called **********\n");
- System.out.println(deptno);
- Dept dept = (Dept) SDOHelperContext.getHelperContext().getDataFactory().create(Dept.class);
- dept.setDeptno(deptno);
- dept.setDname("Dname" + deptno);
+@Stateless(name = "org.eclipse.persistence.testing.sdo.server.DeptServiceBean", mappedName = "DeptServiceBean")
+@Remote
+public class DeptServiceImpl implements DeptService {
+
+ private static final Logger LOGGER = Logger.getLogger(DeptServiceImpl.class.getName());
+
+ public DeptServiceImpl() {
+ }
+
+ public Dept getDept(Integer deptno) {
+ LOGGER.info("\n********** getDept() Called **********\n");
+ LOGGER.info("deptno: " + deptno);
+ Dept dept = (Dept) SDOHelperContext.getHelperContext().getDataFactory().create(Dept.class);
+ dept.setDeptno(deptno);
+ dept.setDname("Dname" + deptno);
dept.setLoc("Loc" + deptno);
return dept;
- }
-
- public boolean updateDept(Dept dept) {
- System.out.println("\n********** updateDept() Called **********\n");
- DeptImpl deptImpl = (DeptImpl) dept;
- SDOHelperContext.getHelperContext().getXMLHelper().save(deptImpl, deptImpl.getType().getURI(), deptImpl.getType().getName());
- return (dept != null);
- }
-}
+ }
+
+ public boolean updateDept(Dept dept) {
+ LOGGER.info("\n********** updateDept() Called **********\n");
+ if (dept == null)
+ return false;
+ DeptImpl deptImpl = (DeptImpl) dept;
+ SDOHelperContext.getHelperContext().getXMLHelper().save(deptImpl, deptImpl.getType().getURI(), deptImpl.getType().getName());
+ return true;
+ }
+}
diff --git a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceInitException.java b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceInitException.java
new file mode 100644
index 0000000..ef2a648
--- /dev/null
+++ b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/DeptServiceInitException.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Iaroslav Savytskyi - August 13/2014 - 2.6.0 - Initial implementation
+ ******************************************************************************/
+package org.eclipse.persistence.testing.sdo.server;
+
+/**
+ * Used to indicate service fail during initialisation
+ */
+public class DeptServiceInitException extends RuntimeException {
+
+ public DeptServiceInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/InitSingleton.java b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/InitSingleton.java
new file mode 100644
index 0000000..96aab0e
--- /dev/null
+++ b/sdo/eclipselink.sdo.test.server/src/org/eclipse/persistence/testing/sdo/server/InitSingleton.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Iaroslav Savytskyi - August 13/2014 - 2.6.0 - Initial implementation
+ ******************************************************************************/
+package org.eclipse.persistence.testing.sdo.server;
+
+import org.eclipse.persistence.sdo.helper.SDOHelperContext;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.net.URL;
+import java.util.logging.Logger;
+
+/**
+ * Context startup listener.
+ *
+ * Responsible for the initialization process.
+ */
+@Singleton
+@Startup
+public class InitSingleton {
+
+ private static final Logger LOGGER = Logger.getLogger(InitSingleton.class.getName());
+
+ @PostConstruct
+ public void init() {
+ LOGGER.info("\n********** init() called **********\n");
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource("org/eclipse/persistence/testing/sdo/server/Dept.xsd");
+ String path = url.toExternalForm();
+ SDOHelperContext.getHelperContext().getXSDHelper().define(url.openStream(), path.substring(0, path.lastIndexOf('/') + 1));
+ LOGGER.info("\n********** initialized **********\n");
+ } catch (Exception e) {
+ LOGGER.info("init() failed with error: " + e.getMessage());
+ e.printStackTrace();
+ throw new DeptServiceInitException(e);
+ }
+ }
+}
diff --git a/sdo/org.eclipse.persistence.sdo/src/org/eclipse/persistence/sdo/helper/delegates/SDOTypeHelperDelegate.java b/sdo/org.eclipse.persistence.sdo/src/org/eclipse/persistence/sdo/helper/delegates/SDOTypeHelperDelegate.java
index db353d6..4eb7274 100644
--- a/sdo/org.eclipse.persistence.sdo/src/org/eclipse/persistence/sdo/helper/delegates/SDOTypeHelperDelegate.java
+++ b/sdo/org.eclipse.persistence.sdo/src/org/eclipse/persistence/sdo/helper/delegates/SDOTypeHelperDelegate.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -15,16 +15,19 @@ package org.eclipse.persistence.sdo.helper.delegates;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import javax.xml.namespace.QName;
-import org.eclipse.persistence.sdo.SDOConstants;
-import org.eclipse.persistence.sdo.SDODataObject;
+import commonj.sdo.helper.HelperContext;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+import org.eclipse.persistence.sdo.SDOConstants;
+import org.eclipse.persistence.sdo.SDODataObject;
import org.eclipse.persistence.sdo.SDOProperty;
import org.eclipse.persistence.sdo.SDOType;
import org.eclipse.persistence.sdo.types.SDOWrapperType;
@@ -47,12 +50,14 @@ import org.eclipse.persistence.oxm.XMLDescriptor;
* <li> SDO Types are available through the getType("commonj.sdo", typeName) method.
* <li> Defines Types from DataObjects.
* </ul>
- */
-public class SDOTypeHelperDelegate implements SDOTypeHelper {
-
- /** Map containing user defined types */
- private Map typesHashMap;
-
+ */
+public class SDOTypeHelperDelegate implements SDOTypeHelper {
+
+ private static final Logger LOGGER = Logger.getLogger(SDOTypeHelperDelegate.class.getName());
+
+ /** Map containing user defined types */
+ private Map typesHashMap;
+
/** Map containing wrapper types */
private Map<QName, SDOType> wrappersHashMap;
@@ -120,24 +125,36 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
private static SDOWrapperType SDO_DOUBLEOBJECT_WRAPPER;
private static SDOWrapperType SDO_FLOATOBJECT_WRAPPER;
private static SDOWrapperType SDO_INTOBJECT_WRAPPER;
- private static SDOWrapperType SDO_LONGOBJECT_WRAPPER;
- private static SDOWrapperType SDO_SHORTOBJECT_WRAPPER;
-
- // create these maps once to avoid threading issues
- static {
- initSDOTypeForSimpleJavaTypeMap();
+ private static SDOWrapperType SDO_LONGOBJECT_WRAPPER;
+ private static SDOWrapperType SDO_SHORTOBJECT_WRAPPER;
+
+ /**
+ * Debug info.
+ *
+ * Content should be the same as in searchSources within {@link SDOTypeHelperDelegate#getType(Class)}
+ */
+ private final static String[] SEARCH_SOURCES_NAMES = {
+ "interfacesToSDOTypeHashMap",
+ "sdoTypeForSimpleJavaType",
+ "typesHashMap",
+ "anonymousTypes",
+ "commonjHashMap"};
+
+ // create these maps once to avoid threading issues
+ static {
+ initSDOTypeForSimpleJavaTypeMap();
}
public SDOTypeHelperDelegate(HelperContext aContext) {
// set context before initializing maps
aHelperContext = aContext;
-
- initCommonjHashMap();
- initCommonjJavaHashMap();
-
- reset();
- }
-
+
+ initCommonjHashMap();
+ initCommonjJavaHashMap();
+
+ reset();
+ }
+
public void initWrapperTypes() {
// List of SDO Types and mappings to XSD Types taken from:
// http://www.osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1
@@ -201,14 +218,14 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
SDO_URI_WRAPPER.addDescriptorToProject(project);
SDO_YEAR_WRAPPER.addDescriptorToProject(project);
SDO_YEARMONTH_WRAPPER.addDescriptorToProject(project);
- SDO_YEARMONTHDAY_WRAPPER.addDescriptorToProject(project);
-
- SDO_STRING_WRAPPER.addDescriptorToProject(project);
- SDO_DATETIME_WRAPPER.addDescriptorToProject(project);
-
- SDO_BOOLEANOBJECT_WRAPPER.addDescriptorToProject(project);
- SDO_BYTEOBJECT_WRAPPER.addDescriptorToProject(project);
- SDO_CHARACTEROBJECT_WRAPPER.addDescriptorToProject(project);
+ SDO_YEARMONTHDAY_WRAPPER.addDescriptorToProject(project);
+
+ SDO_STRING_WRAPPER.addDescriptorToProject(project);
+ SDO_DATETIME_WRAPPER.addDescriptorToProject(project);
+
+ SDO_BOOLEANOBJECT_WRAPPER.addDescriptorToProject(project);
+ SDO_BYTEOBJECT_WRAPPER.addDescriptorToProject(project);
+ SDO_CHARACTEROBJECT_WRAPPER.addDescriptorToProject(project);
SDO_DOUBLEOBJECT_WRAPPER.addDescriptorToProject(project);
SDO_FLOATOBJECT_WRAPPER.addDescriptorToProject(project);
SDO_INTOBJECT_WRAPPER.addDescriptorToProject(project);
@@ -563,58 +580,79 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
/**
* Return the Type for this interfaceClass or null if not found.
* @param interfaceClass is the interface for the DataObject's Type -
- * type.getInstanceClass();
- * @return the Type for this interfaceClass or null if not found.
- */
- public SDOType getType(Class interfaceClass) {
- // Check interfaces-to-types map first:
- SDOType type = (SDOType) getInterfacesToSDOTypeHashMap().get(interfaceClass);
- if (type != null) {
- return type;
- }
-
- type = getTypeForSimpleJavaType(interfaceClass);
- if (type != null) {
- return type;
- }
-
- //types keyed on qname
- Iterator iter = getTypesHashMap().keySet().iterator();
- while (iter.hasNext()) {
- QName key = (QName)iter.next();
- SDOType value = (SDOType) getTypesHashMap().get(key);
-
- if (value.getInstanceClass() == interfaceClass) {
- return value;
- }
- }
-
- //Check in list of anonymous types
- iter = getAnonymousTypes().iterator();
- while(iter.hasNext()) {
- SDOType value = (SDOType)iter.next();
-
- if(value.getInstanceClass() == interfaceClass) {
- return value;
- }
- }
-
- //Check in the commonjHashMap as well.
- iter = this.commonjHashMap.keySet().iterator();
- while (iter.hasNext()) {
- Object key = iter.next();
- SDOType value = (SDOType) commonjHashMap.get(key);
-
- if (value.getInstanceClass() == interfaceClass) {
- return value;
- }
- }
-
-
- return null;
- }
-
- public SDOType getTypeForImplClass(Class implClass) {
+ * type.getInstanceClass();
+ * @return the Type for this interfaceClass or null if not found.
+ */
+ @SuppressWarnings("unchecked")
+ public SDOType getType(Class interfaceClass) {
+ LOGGER.info("Looking for : " + interfaceClass);
+
+ final Object[] searchSources = new Object[] {
+ interfacesToSDOTypeHashMap,
+ sdoTypeForSimpleJavaType,
+ getTypesHashMap().values(),
+ anonymousTypes,
+ commonjHashMap.values()};
+
+ for (int i = 0; i < searchSources.length; i++) {
+ Object searchSource = searchSources[i];
+ if (searchSource == null)
+ continue;
+ SDOType type;
+ if (searchSource instanceof Map) {
+ type = ((Map<Class<?>, SDOType>)searchSource).get(interfaceClass);
+ } else { // collection
+ type = getFromCollection(((Collection<SDOType>)searchSource), interfaceClass);
+ }
+ if (type != null) {
+ LOGGER.info(interfaceClass + " was found in: " + SEARCH_SOURCES_NAMES[i] + '.');
+ return type;
+ }
+ }
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ final StringBuilder log = new StringBuilder();
+ log.append("Not found: ").append(interfaceClass).append('\n');
+ for (int i = 0; i < searchSources.length; i++) { // let's show content of all search sources
+ log.append("Content of ")
+ .append(SEARCH_SOURCES_NAMES[i])
+ .append(": ");
+ final Object searchSource = searchSources[i];
+ if (searchSource == null) {
+ log.append("null");
+ } else {
+ if (searchSource instanceof Map) {
+ log.append(((Map) searchSource).keySet());
+ } else { // collection
+ for (SDOType sdoType : (Collection<SDOType>) searchSource) {
+ log.append(sdoType.getInstanceClass()).append(", ");
+ }
+ }
+ }
+ log.append('\n');
+ }
+ LOGGER.info(log.toString());
+ }
+
+ return null;
+ }
+
+ /**
+ * Looking for interfaceClass within the given collection
+ * @param collection of SDOTypes
+ * @param interfaceClass which contains SDOType we are looking for
+ * @return SDOType with a given interfaceClass or null
+ */
+ private SDOType getFromCollection(Collection<SDOType> collection, Class interfaceClass) {
+ for (SDOType sdoType : collection) {
+ if (sdoType.getInstanceClass() == interfaceClass) {
+ return sdoType;
+ }
+ }
+ return null;
+ }
+
+ public SDOType getTypeForImplClass(Class implClass) {
SDOType type = getTypeForSimpleJavaType(implClass);
if (type != null) {
return type;
@@ -849,13 +887,13 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
newProperty.setXsdType(XMLConstants.BASE_64_BINARY_QNAME);
}
}
- }
-
- newProperty.setAppInfoElements((List) dataObject.get(SDOConstants.APPINFO));
-
- if (dataObject.isSet("containment")) {
- newProperty.setContainment(dataObject.getBoolean("containment"));
- } else {
+ }
+
+ newProperty.setAppInfoElements((List) dataObject.get(SDOConstants.APPINFO));
+
+ if (dataObject.isSet("containment")) {
+ newProperty.setContainment(dataObject.getBoolean("containment"));
+ } else {
if (typeValue != null) {
newProperty.setContainment(!((SDOType)typeValue).isDataType());
}
@@ -1015,13 +1053,13 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
@throws IllegalArgumentException if the Property could not be defined.
*/
public Property defineOpenContentProperty(String uri, DataObject propertyDO) {
- if (propertyDO == null) {
- throw new IllegalArgumentException(SDOException.cannotPerformOperationWithNullInputParameter("defineOpenContentProperty", "propertyDO"));
- }
-
- String name = propertyDO.getString("name");
- Property propertyToReturn = aHelperContext.getXSDHelper().getGlobalProperty(uri, name, true);
- if (propertyToReturn == null) {
+ if (propertyDO == null) {
+ throw new IllegalArgumentException(SDOException.cannotPerformOperationWithNullInputParameter("defineOpenContentProperty", "propertyDO"));
+ }
+
+ String name = propertyDO.getString("name");
+ Property propertyToReturn = aHelperContext.getXSDHelper().getGlobalProperty(uri, name, true);
+ if (propertyToReturn == null) {
propertyToReturn = aHelperContext.getXSDHelper().getGlobalProperty(uri, name, false);
}
@@ -1033,30 +1071,30 @@ public class SDOTypeHelperDelegate implements SDOTypeHelper {
}
if (propertyToReturn != null) {
- Object propDOType = propertyDO.get("type");
- SDOType existingType = (SDOType) propertyToReturn.getType();
- boolean typeMismatch = false;
-
- if (propDOType instanceof SDOType) {
- SDOType newType = (SDOType) propDOType;
- if (!newType.getQName().equals(existingType.getQName())) {
+ Object propDOType = propertyDO.get("type");
+ SDOType existingType = (SDOType) propertyToReturn.getType();
+ boolean typeMismatch = false;
+
+ if (propDOType instanceof SDOType) {
+ SDOType newType = (SDOType) propDOType;
+ if (!newType.getQName().equals(existingType.getQName())) {
typeMismatch = true;
}
} else if (propDOType instanceof DataObject) {
DataObject newTypeDO = (DataObject) propDOType;
if (!newTypeDO.get("name").equals(existingType.getName()) || !newTypeDO.get("uri").equals(existingType.getURI())) {
- typeMismatch = true;
- }
- }
-
- if (typeMismatch) {
- throw new IllegalArgumentException("Should not be able to redefine a Property with a different Type.");
- }
- }
-
- return propertyToReturn;
- }
-
+ typeMismatch = true;
+ }
+ }
+
+ if (typeMismatch) {
+ throw new IllegalArgumentException("Should not be able to redefine a Property with a different Type.");
+ }
+ }
+
+ return propertyToReturn;
+ }
+
/**
* INTERNAL:
* @param propertyQName