From 590ec58662abf12c08a1de0c5cd3616c960f04cb Mon Sep 17 00:00:00 2001 From: Ryan D. Brooks Date: Fri, 19 Aug 2011 09:32:51 -0700 Subject: refinement: Improve performance of session creation --- .../core/model/cache/AbstractOseeCache.java | 4 +++ .../META-INF/MANIFEST.MF | 8 ++--- .../OSGI-INF/service.provider.xml | 5 +++ .../osee/framework/core/server/UserDataStore.java | 13 ++++++-- .../core/server/internal/ServiceProvider.java | 37 ++++++++++++++++++++++ 5 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 plugins/org.eclipse.osee.framework.core.server/OSGI-INF/service.provider.xml create mode 100644 plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ServiceProvider.java diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java index 447fd71f3bd..78242798818 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java @@ -325,4 +325,8 @@ public abstract class AbstractOseeCache implements I } } } + + public final int getLocalId(Identity token) throws OseeCoreException { + return get(token).getId(); + } } diff --git a/plugins/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF index fdf32d68545..696599db2e8 100644 --- a/plugins/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF @@ -16,6 +16,7 @@ Import-Package: javax.servlet, org.eclipse.osee.framework.core.model, org.eclipse.osee.framework.core.model.cache, org.eclipse.osee.framework.core.operation, + org.eclipse.osee.framework.core.services, org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.database, org.eclipse.osee.framework.database.core, @@ -29,10 +30,5 @@ Import-Package: javax.servlet, Eclipse-ExtensibleAPI: true Export-Package: org.eclipse.osee.framework.core.server Bundle-ActivationPolicy: lazy -Service-Component: OSGI-INF/authentication.manager.xml, - OSGI-INF/authentication.provider.xml, - OSGI-INF/authentication.provider.demo.xml, - OSGI-INF/application.lookup.server.manager.xml, - OSGI-INF/server.task.scheduler.xml, - OSGI-INF/join.cleanup.task.provider.xml +Service-Component: OSGI-INF/*.xml Bundle-Activator: org.eclipse.osee.framework.core.server.internal.ServerActivator diff --git a/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/service.provider.xml b/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/service.provider.xml new file mode 100644 index 00000000000..10026e70eca --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/service.provider.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/UserDataStore.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/UserDataStore.java index b1b4762e73a..6c775f1ead7 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/UserDataStore.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/UserDataStore.java @@ -13,8 +13,13 @@ package org.eclipse.osee.framework.core.server; import java.util.logging.Level; import org.eclipse.osee.framework.core.data.IUserToken; import org.eclipse.osee.framework.core.data.TokenFactory; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.core.enums.CoreBranches; +import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.server.internal.ServerActivator; +import org.eclipse.osee.framework.core.server.internal.ServiceProvider; +import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.logging.OseeLog; @@ -24,7 +29,7 @@ import org.eclipse.osee.framework.logging.OseeLog; */ public final class UserDataStore { private static final String LOAD_OSEE_USER = - "select oa.value as user_id from osee_attribute_type oat, osee_attribute oa, osee_txs txs where oat.name = 'User Id' and oat.attr_type_id = oa.attr_type_id and oa.gamma_id = txs.gamma_id and txs.tx_current = 1 and oa.value = ?"; + "select att.value as user_id from osee_attribute att, osee_txs txs where att.attr_type_id = ? and txs.branch_id = ? and att.gamma_id = txs.gamma_id and txs.tx_current = ? and att.value = ?"; private UserDataStore() { // private constructor @@ -33,9 +38,13 @@ public final class UserDataStore { public static IUserToken getUserTokenFromOseeDb(String userId) { IUserToken toReturn = null; IOseeStatement chStmt = null; + IOseeCachingService cachingService = ServiceProvider.getCachingService(); try { + int attributeTypeId = cachingService.getAttributeTypeCache().getLocalId(CoreAttributeTypes.UserId); + int branchId = cachingService.getBranchCache().get(CoreBranches.COMMON).getId(); + chStmt = ConnectionHandler.getStatement(); - chStmt.runPreparedQuery(LOAD_OSEE_USER, userId); + chStmt.runPreparedQuery(LOAD_OSEE_USER, attributeTypeId, branchId, TxChange.CURRENT.getValue(), userId); if (chStmt.next()) { // Only need the userId all other fields will be loaded by the client toReturn = TokenFactory.createUserToken(null, "-", "-", chStmt.getString("user_id"), true, false, false); diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ServiceProvider.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ServiceProvider.java new file mode 100644 index 00000000000..afa3914a334 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ServiceProvider.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.core.server.internal; + +import org.eclipse.osee.framework.core.services.IOseeCachingService; + +/** + * @author Ryan D. Brooks + */ +public class ServiceProvider { + private IOseeCachingService service; + private static ServiceProvider instance; + + public void setCachingService(IOseeCachingService service) { + this.service = service; + } + + public static IOseeCachingService getCachingService() { + return instance.service; + } + + public void start() { + instance = this; + } + + public void stop() { + instance = null; + } +} \ No newline at end of file -- cgit v1.2.3