From 9a6227be5bad1a843f2a75c2a3bde5a8f1d84925 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Tue, 27 May 2014 21:33:39 +0200 Subject: [PATCH] renamed backend summary lines. --- .../vasc/backend/AbstractVascBackend.java | 8 +- .../forwardfire/vasc/backend/VascBackend.java | 6 +- .../vasc/backend/ldap/LdapVascBackend.java | 105 +++++++++--------- .../vasc/ejb3/VascServiceRemoteBackend.java | 4 +- .../proxy/AbstractVascBackendProxy.java | 12 +- .../vasc/impl/type/FieldTypeDriver.java | 1 - .../impl/x4o/VascEntryFieldTypeElement.java | 5 +- .../core/service/VascControllerService.java | 39 ++++++- .../demo/server/tomcat/JndiVascDeployer.java | 6 +- 9 files changed, 108 insertions(+), 78 deletions(-) diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java index 117cc3c..cfa6d45 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java @@ -133,16 +133,16 @@ abstract public class AbstractVascBackend implements VascBackend { } /** - * @see net.forwardfire.vasc.backend.VascBackend#isPageSummary() + * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() */ - public boolean isPageSummary() { + public boolean hasPageSummary() { return false; } /** - * @see net.forwardfire.vasc.backend.VascBackend#isTotalSummary() + * @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary() */ - public boolean isTotalSummary() { + public boolean hasTotalSummary() { return false; } } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java index c522e5b..644e8c5 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; /** + * VascBackend provides stateless data access to a data source. * * @author Willem Cazander * @version 1.0 Mar 21, 2007 @@ -48,7 +49,6 @@ public interface VascBackend { public void delete(Object object) throws VascBackendException; - /** * Creates a new Field acces obj the the given field entry. * note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle. @@ -96,10 +96,10 @@ public interface VascBackend { public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException; - public boolean isPageSummary(); + public boolean hasPageSummary(); public Map executePageSummary(); - public boolean isTotalSummary(); + public boolean hasTotalSummary(); public Map executeTotalSummary(); /* diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java index 1fdf788..1c57216 100644 --- a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java +++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.VascBackendException; @@ -40,19 +41,20 @@ import com.novell.ldap.LDAPAttribute; import com.novell.ldap.LDAPAttributeSet; import com.novell.ldap.LDAPConnection; import com.novell.ldap.LDAPEntry; +import com.novell.ldap.LDAPException; import com.novell.ldap.LDAPModification; import com.novell.ldap.LDAPSearchConstraints; import com.novell.ldap.LDAPSearchResults; /** - * Provides backend for ldap. + * LdapVascBackend provides abstract data access for ldap. * * @author Willem Cazander * @version 1.0 Sep 4, 2008 */ public class LdapVascBackend extends AbstractVascBackend { - - + + private Logger logger = Logger.getLogger(LdapVascBackend.class.getName()); private LdapConnectionProvider ldapConnectionProvider = null; private String baseDN = null; private String keyAttribute = null; @@ -62,14 +64,14 @@ public class LdapVascBackend extends AbstractVascBackend { private boolean referralFollowing = true; /** - * @return the ldapConnectionProvider + * @return the ldapConnectionProvider. */ public LdapConnectionProvider getLdapConnectionProvider() { return ldapConnectionProvider; } - + /** - * @param ldapConnectionProvider the ldapConnectionProvider to set + * @param ldapConnectionProvider the ldapConnectionProvider to set. */ public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) { this.ldapConnectionProvider = ldapConnectionProvider; @@ -121,16 +123,14 @@ public class LdapVascBackend extends AbstractVascBackend { } result.add(map); } - } catch (Exception e) { + } catch (LDAPException e) { throw new VascBackendException(e); } finally { - if (connection!=null) { - connection.clone(); - } + safeDisconnect(connection); } return result; } - + /** * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) */ @@ -205,15 +205,13 @@ public class LdapVascBackend extends AbstractVascBackend { connection.modify(entry.getDN(), m); return object; - } catch (Exception e) { + } catch (LDAPException e) { throw new VascBackendException(e); } finally { - if (connection!=null) { - connection.clone(); - } + safeDisconnect(connection); } } - + /** * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) */ @@ -242,12 +240,10 @@ public class LdapVascBackend extends AbstractVascBackend { entry.getAttributeSet().add(attr); } connection.add(entry); - } catch (Exception e) { + } catch (LDAPException e) { throw new VascBackendException(e); } finally { - if (connection!=null) { - connection.clone(); - } + safeDisconnect(connection); } } @@ -276,12 +272,21 @@ public class LdapVascBackend extends AbstractVascBackend { } LDAPEntry entry = searchResults.next(); connection.delete(entry.getDN()); - } catch (Exception e) { + } catch (LDAPException e) { throw new VascBackendException(e); } finally { - if (connection!=null) { - connection.clone(); - } + safeDisconnect(connection); + } + } + + private void safeDisconnect(LDAPConnection connection) { + if (connection==null) { + return; + } + try { + connection.disconnect(); + } catch (LDAPException e) { + logger.warning("Error while disconnecting: "+e.getMessage()); } } @@ -291,95 +296,95 @@ public class LdapVascBackend extends AbstractVascBackend { public VascEntryRecordCreator provideVascEntryRecordCreator() { return new MapVascEntryRecordCreator(); } - + /** * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue() */ public VascEntryFieldValue provideVascEntryFieldValue() { return new MapVascEntryFieldValue(); } - + /** - * @return the baseDN + * @return the baseDN. */ public String getBaseDN() { return baseDN; } - + /** - * @param baseDN the baseDN to set + * @param baseDN the baseDN to set. */ public void setBaseDN(String baseDN) { this.baseDN = baseDN; } - + /** - * @return the keyAttribute + * @return the keyAttribute. */ public String getKeyAttribute() { return keyAttribute; } - + /** - * @param keyAttribute the keyAttribute to set + * @param keyAttribute the keyAttribute to set. */ public void setKeyAttribute(String keyAttribute) { this.keyAttribute = keyAttribute; } - + /** - * @return the ldapFilter + * @return the ldapFilter. */ public String getLdapFilter() { return ldapFilter; } - + /** - * @param ldapFilter the ldapFilter to set + * @param ldapFilter the ldapFilter to set. */ public void setLdapFilter(String ldapFilter) { this.ldapFilter = ldapFilter; } - + /** - * @return the createObjectClass + * @return the createObjectClass. */ public String getCreateObjectClass() { return createObjectClass; } - + /** - * @param createObjectClass the createObjectClass to set + * @param createObjectClass the createObjectClass to set. */ public void setCreateObjectClass(String createObjectClass) { this.createObjectClass = createObjectClass; } - + /** - * @return the timeLimit + * @return the timeLimit. */ public int getTimeLimit() { return timeLimit; } - + /** - * @param timeLimit the timeLimit to set + * @param timeLimit the timeLimit to set. */ public void setTimeLimit(int timeLimit) { this.timeLimit = timeLimit; } - + /** - * @return the referralFollowing + * @return the referralFollowing. */ public boolean isReferralFollowing() { return referralFollowing; } - + /** - * @param referralFollowing the referralFollowing to set + * @param referralFollowing the referralFollowing to set. */ public void setReferralFollowing(boolean referralFollowing) { this.referralFollowing = referralFollowing; } -} \ No newline at end of file +} diff --git a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java index 6aee68b..a72480a 100644 --- a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java +++ b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java @@ -168,13 +168,13 @@ public class VascServiceRemoteBackend implements VascBackend { return (Map)result; } - public boolean isPageSummary() { + public boolean hasPageSummary() { Object[] args = new Object[0]; Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args); return (Boolean)result; } - public boolean isTotalSummary() { + public boolean hasTotalSummary() { Object[] args = new Object[0]; Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args); return (Boolean)result; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java index ddfe740..4047bc6 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java @@ -208,16 +208,16 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.VascBackend#isPageSummary() + * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() */ - public boolean isPageSummary() { - return backend.isPageSummary(); + public boolean hasPageSummary() { + return backend.hasPageSummary(); } /** - * @see net.forwardfire.vasc.backend.VascBackend#isTotalSummary() + * @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary() */ - public boolean isTotalSummary() { - return backend.isTotalSummary(); + public boolean hasTotalSummary() { + return backend.hasTotalSummary(); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeDriver.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeDriver.java index deef907..88ad6c6 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeDriver.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeDriver.java @@ -40,7 +40,6 @@ import org.x4o.xml.element.Element; import org.x4o.xml.io.X4OConnectionException; import org.x4o.xml.io.X4OReaderSession; import org.x4o.xml.lang.X4OLanguageSession; -import org.x4o.xml.lang.X4OLanguageSessionLocal; import org.x4o.xml.lang.phase.X4OPhaseException; /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldTypeElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldTypeElement.java index f1c780e..5eb0375 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldTypeElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldTypeElement.java @@ -30,8 +30,6 @@ import net.forwardfire.vasc.core.VascEntryFieldType; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; -import org.x4o.xml.lang.phase.X4OPhase; - /** * VascEntryFieldTypeElement @@ -56,7 +54,6 @@ public class VascEntryFieldTypeElement extends AbstractElement { VascEntryFieldType type = field.getVascEntryFieldType(); setElementObject(type); logger.info("Readding the element for reparsing"); - X4OPhase startX4OPhase = getLanguageSession().getLanguage().getPhaseManager().getPhase("READ_CONFIG_ELEMENT"); // TODO: back to enum ? - getLanguageSession().addDirtyElement(this, startX4OPhase); + getLanguageSession().addDirtyElement(this); } } \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java index 50e8b86..40fb060 100644 --- a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java +++ b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java @@ -34,6 +34,8 @@ import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; import java.util.logging.Logger; import org.x4o.xml.io.X4OReader; @@ -65,11 +67,32 @@ public class VascControllerService { private Logger logger = null; private VascController vascController = null; + private Timer delayedI18nTimer; + private I18NVascEventControllerListener i18nGenerator; + private static final long TASK_DELAY = 1000*13; + int bootDone = 20; public VascControllerService() { logger = Logger.getLogger(VascControllerService.class.getName()); + i18nGenerator = new I18NVascEventControllerListener(); + delayedI18nTimer = new Timer("i18n-generator"); + delayedI18nTimer.schedule(new DelayedTask(), TASK_DELAY + TASK_DELAY); } + class DelayedTask extends TimerTask { + @Override + public void run() { + if (i18nGenerator.generateRequest!=0) { + i18nGenerator.generateBundle(); + i18nGenerator.generateRequest=0; + } + bootDone--; + if (bootDone > 0) { + delayedI18nTimer.schedule(new DelayedTask(), TASK_DELAY); + } + } + }; + public void start() { logger.finer("Starting vascmanager"); if (vascController!=null) { @@ -81,16 +104,17 @@ public class VascControllerService { } catch (Exception e) { throw new RuntimeException(e); } - + // Inject our i18n listener for hot deploy demo VascEventChannelControllerLocal ev = (VascEventChannelControllerLocal)vascController.getVascEventChannelController(); - ev.addVascEventControllerListener(new I18NVascEventControllerListener()); - + ev.addVascEventControllerListener(i18nGenerator); } public void stop() { if (vascController==null) { return; } + delayedI18nTimer.cancel(); + VascBackendControllerLocal backends = (VascBackendControllerLocal)vascController.getVascBackendController(); backends.clearAndStopBackends(); @@ -122,7 +146,9 @@ public class VascControllerService { } class I18NVascEventControllerListener implements VascEventControllerListener { - + + public long generateRequest = 0; + @Override public VascEventControllerType[] getVascEventControllerTypes() { return new VascEventControllerType[] {VascEventControllerType.LOAD_ENTRIES_AFTER}; @@ -130,7 +156,10 @@ public class VascControllerService { @Override public void controllerEvent(VascEventControllerType type,Object eventObject) { - + generateRequest = System.currentTimeMillis(); + } + + public void generateBundle() { logger.info("Regenerating resource bundle keys..."); Map keys = new HashMap(300); diff --git a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/tomcat/JndiVascDeployer.java b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/tomcat/JndiVascDeployer.java index aa2d120..5c25cde 100644 --- a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/tomcat/JndiVascDeployer.java +++ b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/tomcat/JndiVascDeployer.java @@ -89,7 +89,7 @@ public class JndiVascDeployer { scanThread.start(); } - public void stop() { + public void stop() { if (autoDeployManager==null) { return; } @@ -116,7 +116,6 @@ public class JndiVascDeployer { } } } - private void hotDeployVasc() throws NoSuchAlgorithmException, IOException { int deployed = 0; @@ -165,7 +164,7 @@ public class JndiVascDeployer { //fireChangeEvent(); } } - + protected class AutoDeployManager implements Runnable { private volatile boolean run = true; public void run() { @@ -211,6 +210,7 @@ public class JndiVascDeployer { logger.info("AutoDeployManager stoped"); } } + public void stop() { run = false; this.notify();