final Map<Class, ClassDescriptor> descriptors = session.getDescriptors(); final ClassDescriptor descriptor = session.getDescriptor(expectedType);
/** * INTERNAL: Add and initialize a new session to the list of sessions * associated with this XMLContext. */ public void addSession(DatabaseSession sessionToAdd) { if ((sessionToAdd.getDatasourceLogin() == null) || !(sessionToAdd.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) { XMLPlatform platform = new SAXPlatform(); sessionToAdd.setLogin(new XMLLogin(platform)); } DatabaseSession session = sessionToAdd.getProject().createDatabaseSession(); if (sessionToAdd.getEventManager().hasListeners()) { List listeners = sessionToAdd.getEventManager().getListeners(); int listenersSize = listeners.size(); for (int x = 0; x < listenersSize; x++) { session.getEventManager().addListener((SessionEventListener) listeners.get(x)); } } session.setExceptionHandler(sessionToAdd.getExceptionHandler()); session.setLogLevel(SessionLog.OFF); this.setupDocumentPreservationPolicy(session); session.login(); sessions.add(session); storeXMLDescriptorsByQName(session); }
/** * Returns conversion manager from session datasource platform. * * @return conversion manager */ public ConversionManager getOxmConversionManager() { return (org.eclipse.persistence.internal.oxm.ConversionManager) getSession().getDatasourcePlatform().getConversionManager(); }
private void destroy(DatabaseSession session) { if (session.isConnected()) { session.logout(); } sessions.remove(session.getName()); session = null; }
@Override protected void setupSession(DatabaseSession session) { session.setLogLevel(SessionLog.OFF); session.login(); setupDocumentPreservationPolicy(session); }
public void missingDescriptor(SessionEvent event) { String name = ((Class)event.getResult()).getName(); DatabaseSession session = (DatabaseSession) ((AbstractSession) event.getSession()).getRootSession(null); Project project = session.getProject(); String namespaceXPath = ""; NamespaceResolverWithPrefixes namespaceResolverWithPrefixes; javaClass = PrivilegedAccessHelper.getClassForName(XML_INTERACTION_CLASS); session.getDescriptor(Call.class).getInheritancePolicy().addClassIndicator(javaClass, namespaceXPath + "xml-interaction" ); } catch (Exception classLoadFailure) { throw ValidationException.fatalErrorOccurred(classLoadFailure); session.addDescriptors(new EISObjectPersistenceXMLProject(namespaceResolverWithPrefixes)); session.addDescriptors(new OXMObjectPersistenceRuntimeXMLProject(namespaceResolverWithPrefixes));
public DynamicHelper(DatabaseSession session) { this.session = session; Collection<ClassDescriptor> descriptors = session.getDescriptors().values(); for (ClassDescriptor desc : descriptors) { if (desc.getJavaClassName() != null) { fqClassnameToDescriptor.put(desc.getJavaClassName(), desc); } } }
private void setupDocumentPreservationPolicy(DatabaseSession session) { XMLLogin login = (XMLLogin) session.getDatasourceLogin(); if (login.getDocumentPreservationPolicy() == null) { Iterator iterator = session.getProject().getOrderedDescriptors().iterator(); while (iterator.hasNext()) { Descriptor xmlDescriptor = (Descriptor) iterator.next(); if (xmlDescriptor.shouldPreserveDocument()) { login.setDocumentPreservationPolicy(new DescriptorLevelDocumentPreservationPolicy()); break; } } } if (login.getDocumentPreservationPolicy() == null) { login.setDocumentPreservationPolicy(new NoDocumentPreservationPolicy()); } login.getDocumentPreservationPolicy().initialize(context); if (login.getDocumentPreservationPolicy().shouldPreserveDocument() && !hasDocumentPreservation) { hasDocumentPreservation = true; } }
/** * Add one or more EntityType instances to a session and optionally generate * needed tables with or without FK constraints. * * @param session * @param createMissingTables * @param generateFKConstraints * @param types */ public void addTypes(boolean createMissingTables, boolean generateFKConstraints, DynamicType... types) { if (types == null || types.length == 0) { throw new IllegalArgumentException("No types provided"); } Collection<ClassDescriptor> descriptors = new ArrayList<ClassDescriptor>(types.length); for (int index = 0; index < types.length; index++) { descriptors.add(types[index].getDescriptor()); if (!types[index].getDescriptor().requiresInitialization()) { types[index].getDescriptor().getInstantiationPolicy().initialize((AbstractSession) session); } } session.addDescriptors(descriptors); if (createMissingTables) { if (!getSession().isConnected()) { getSession().login(); } new DynamicSchemaManager(session).createTables(generateFKConstraints, types); } }
final ClassLoader cl = getServerSession().getDatasourcePlatform().getConversionManager().getLoader(); for (ClassDescriptor desc : this.getServerSession().getDescriptors().values()) { if (version.compareTo(ServiceVersion.VERSION_2_0) >= 0) {
private void storeXMLDescriptorsByQName(DatabaseSession session) { Iterator iterator = session.getProject().getOrderedDescriptors().iterator(); while (iterator.hasNext()) { XMLDescriptor xmlDescriptor = (XMLDescriptor) iterator.next(); storeXMLDescriptorByQName(xmlDescriptor); } }
private void initialize(Map<String, Boolean> parserFeatures) { DatabaseSession session = xmlContext.getSession(0); XMLPlatform xmlPlatform = (XMLPlatform)session.getDatasourceLogin().getDatasourcePlatform(); platformUnmarshaller = xmlPlatform.newPlatformUnmarshaller(this, parserFeatures); platformUnmarshaller.setWhitespacePreserving(false); unmarshalProperties = new Properties(); // Waiting on XDK to fix bug #3697940 to enable this code //initializeSchemas(); setValidationMode(NONVALIDATING); }
/** * Return the class (interface) for the WebSphere JDBC connection wrapper. */ protected Class getWebsphereConnectionClass() { if (this.websphereConnectionClass == null) { try { this.websphereConnectionClass = (Class) getDatabaseSession().getPlatform().convertObject("com.ibm.ws.rsadapter.jdbc.WSJdbcConnection", Class.class); } catch (Throwable exception) { getDatabaseSession().getSessionLog().logThrowable(SessionLog.WARNING, exception); this.websphereConnectionClass = void.class; } } return this.websphereConnectionClass; }
private MetadataCatalog buildMetadataCatalog(PersistenceContext context) { final MetadataCatalog result = new MetadataCatalog(); // Entities final Map<Class, ClassDescriptor> descriptors = context.getServerSession().getDescriptors(); for (Class clazz : descriptors.keySet()) { ClassDescriptor descriptor = descriptors.get(clazz); // Skip embeddables if (!descriptor.isAggregateDescriptor()) { result.addResource(buildEntityMetadata(context, descriptor)); } } // Queries final Map<String, List<DatabaseQuery>> allQueries = context.getServerSession().getQueries(); for (List<DatabaseQuery> databaseQueries : allQueries.values()) { if (databaseQueries != null) { for (DatabaseQuery query : databaseQueries) { if (query.getReferenceClassName() != null) { result.addResource(buildQueryMetadata(context, query)); } } } } final String href = HrefHelper.buildMetadataCatalogHref(context); final List<LinkV2> links = (new ItemLinksBuilder()) .addCanonical(href) .getList(); result.setLinks(links); return result; }
/** * Return the method for the WebLogic JDBC connection wrapper vendorConnection. */ protected Method getVendorConnectionMethod() { if ((this.vendorConnectionMethod == null) && (!getWebLogicConnectionClass().equals(void.class))) { try { this.vendorConnectionMethod = PrivilegedAccessHelper.getDeclaredMethod(getWebLogicConnectionClass(), "getVendorConnection", new Class[0]); } catch (NoSuchMethodException exception) { getDatabaseSession().getSessionLog().logThrowable(SessionLog.WARNING, exception); } } return this.vendorConnectionMethod; }
/** * Remove a dynamic type from the system. * * This implementation assumes that the dynamic type has no relationships to * it and that it is not involved in an inheritance relationship. If there * are concurrent processes using this type when it is removed some * exceptions may occur. * * @param session * @param typeName */ public void removeType(String typeName) { DynamicType type = getType(typeName); if (type != null) { getSession().getIdentityMapAccessor().initializeIdentityMap(type.getJavaClass()); ClassDescriptor descriptor = type.getDescriptor(); getSession().getProject().getOrderedDescriptors().remove(descriptor); getSession().getProject().getDescriptors().remove(type.getJavaClass()); } }
session.getEventManager().addListener(sessionEventListener); session.setLogLevel(SessionLog.OFF); session.login(); sessions.add(session); descriptorsByQName = new HashMap();
Descriptor desc = (Descriptor) xmlBinder.getMarshaller().getXMLContext().getSession().getClassDescriptor(updatedObj);
/** * Gets the descriptor for class. * * @param clazz the clazz * @return the descriptor for class */ @SuppressWarnings("rawtypes") public ClassDescriptor getDescriptorForClass(Class clazz) { DatabaseSession session = getServerSession(); ClassDescriptor descriptor = session.getDescriptor(clazz); if (descriptor == null) { return getJAXBDescriptorForClass(clazz); } return descriptor; }