[jbosstools-commits] JBoss Tools SVN: r43491 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 6 20:37:05 EDT 2012
Author: scabanovich
Date: 2012-09-06 20:37:04 -0400 (Thu, 06 Sep 2012)
New Revision: 43491
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDICache.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProjectAsYouType.java
Log:
JBIDE-12446
https://issues.jboss.org/browse/JBIDE-12446
Interface ICDICache added.
Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDICache.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDICache.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDICache.java 2012-09-07 00:37:04 UTC (rev 43491)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core;
+
+import java.util.Collection;
+
+public interface ICDICache {
+
+ /**
+ * Cleans from database all data related to the project,
+ * and creates tables for beans, legal types, and connections between them.
+ *
+ * @param project
+ * @param bean
+ */
+ public void rebuild(ICDIProject project, Collection<IBean> bean);
+
+ /**
+ * Returns all beans that has 'legalType' as one of legal types.
+ *
+ * @param project
+ * @param legalType
+ * @return
+ */
+ public Collection<IBean> getBeansByLegalType(ICDIProject project, String legalType);
+
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDICache.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIElement.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIElement.java 2012-09-07 00:33:48 UTC (rev 43490)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIElement.java 2012-09-07 00:37:04 UTC (rev 43491)
@@ -21,6 +21,12 @@
public interface ICDIElement {
/**
+ * Returns unique id of this object. It is assigned only for the current session.
+ * @return
+ */
+ int getId();
+
+ /**
* Returns CDI project that contains this object.
* @return
*/
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIElement.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIElement.java 2012-09-07 00:33:48 UTC (rev 43490)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIElement.java 2012-09-07 00:37:04 UTC (rev 43491)
@@ -28,9 +28,21 @@
*
*/
public abstract class CDIElement implements ICDIElement {
+ static int LAST_ID = 0;
+ protected int id;
protected ICDIElement parent;
protected IPath source;
+ public CDIElement() {
+ synchronized (this) {
+ id = LAST_ID++;
+ }
+ }
+
+ public int getId() {
+ return id;
+ }
+
@Override
public ICDIProject getCDIProject() {
return parent != null ? parent.getCDIProject() : null;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2012-09-07 00:33:48 UTC (rev 43490)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2012-09-07 00:37:04 UTC (rev 43491)
@@ -40,6 +40,7 @@
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.IBuiltInBean;
import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.ICDICache;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IDecorator;
@@ -85,11 +86,13 @@
private ICDIProject declaringProject = this;
private CDICache cache = new CDICache();
+ private ICDICache dbCache;
BeansXMLData allBeansXMLData = new BeansXMLData();
BeansXMLData projectBeansXMLData = new BeansXMLData();
public CDIProject() {
+ //TODO create dbCache instance
}
public CDIProject getModifiedCopy(IFile file, Collection<IBean> beans) {
@@ -368,6 +371,14 @@
String injectionPointName = injectionPoint.getBeanName();
+ Collection<IBean> beans = null;
+
+ //DB
+ if(dbCache != null) {
+ beans = dbCache.getBeansByLegalType(this, type.getType().getFullyQualifiedName());
+ }
+ //Compare with result from cache.
+
for (IBean b: cache.getBeansByLegalType(type)) {
if(isObjectType || containsType(b.getLegalTypes(), type)) {
try {
@@ -1121,6 +1132,11 @@
bp.buildBeans(this);
}
}
+
+ // DB
+ if(dbCache != null) {
+ dbCache.rebuild(this, cache.getAllBeans());
+ }
Set<IBeanStoreFeature> beanStores = n.getExtensionManager().getFeatures(IBeanStoreFeature.class);
for (IBeanStoreFeature bp: beanStores) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProjectAsYouType.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProjectAsYouType.java 2012-09-07 00:33:48 UTC (rev 43490)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProjectAsYouType.java 2012-09-07 00:37:04 UTC (rev 43491)
@@ -607,4 +607,9 @@
return project.isClassAlternativeActivated(fullQualifiedTypeName);
}
+ @Override
+ public int getId() {
+ return ((ICDIElement)project).getId();
+ }
+
}
More information about the jbosstools-commits
mailing list