notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2729 - development/main/transit/core/handler/src/main/net/dpml/transit/builder
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2729 - development/main/transit/core/handler/src/main/net/dpml/transit/builder
- Date: Sun, 05 Jun 2005 18:30:02 -0400
Author: mcconnell AT dpml.net
Date: Sun Jun 5 18:30:01 2005
New Revision: 2729
Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryStorageHome.java
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
Log:
Put in place active storage management for the repository service sub-system.
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
Sun Jun 5 18:30:01 2005
@@ -64,6 +64,7 @@
private boolean m_purgePolicy = false;
private ProxyStorageHome m_proxyHome;
+ private RepositoryStorageHome m_repositoryHome;
//
------------------------------------------------------------------------
// ModificationListener
@@ -183,14 +184,14 @@
//
m_proxyHome = createProxyHome( creation );
- ProxyManager proxy = m_proxyHome.create();
+ m_repositoryHome = createRepositoryHome( creation );
+ ProxyManager proxy = m_proxyHome.create();
+ RepositoryManager repository = m_repositoryHome.create();
- //ProxyManager proxy = createProxyManager( creation );
LayoutRegistryManager layout = createLayoutRegistryManager( creation
);
CacheManager cache = createCacheManager( creation, layout );
ContentRegistryManager content = createContentRegistryManager(
creation );
- RepositoryManager repository = createRepositoryManager( creation );
ModificationListener store = null;
if( m_savePolicy )
@@ -277,6 +278,7 @@
}
}
+ /*
private RepositoryManager createRepositoryManager( Date creation )
throws BuilderException
{
try
@@ -292,6 +294,25 @@
throw new BuilderException( error, e );
}
}
+ */
+
+ private RepositoryStorageHome createRepositoryHome( Date creation )
throws BuilderException
+ {
+ try
+ {
+ boolean policy = getStoragePolicy();
+ Logger logger = getLogger().getChildLogger( "repository" );
+ Preferences prefs = getPreferences().node( "repository" );
+ return new RepositoryStorageHome( prefs, logger, creation,
policy );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error occured during construction of the repository
storage home.";
+ throw new BuilderException( error, e );
+ }
+ }
+
private Preferences getPreferences()
{
Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryStorageHome.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryStorageHome.java
Sun Jun 5 18:30:01 2005
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.builder;
+
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+import java.util.Date;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.management.RepositoryManager;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;
+import net.dpml.transit.manager.DefaultRepositoryManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+class RepositoryStorageHome extends AbstractStorageHome
+{
+ private ModificationListener m_listener;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ RepositoryStorageHome( Preferences prefs, Logger logger, Date creation,
boolean policy )
+ {
+ super( prefs, logger, creation, policy );
+ if( policy )
+ {
+ m_listener = new StorageListener();
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // internalization
+ //
------------------------------------------------------------------------
+
+ public RepositoryManager create()
+ throws BuilderException
+ {
+ Preferences prefs = getPreferences();
+ Logger logger = getLogger();
+ Date creation = getCreationDate();
+ URI uri = getURI( "uri" );
+ DefaultRepositoryManager manager = new DefaultRepositoryManager(
logger, creation, uri );
+ if( null != m_listener )
+ {
+ manager.addModificationListener( m_listener );
+ }
+ return manager;
+ }
+
+ //
------------------------------------------------------------------------
+ // externalization
+ //
------------------------------------------------------------------------
+
+ public void setRepositoryManager( RepositoryManager manager )
+ throws BuilderException
+ {
+ Preferences prefs = getPreferences();
+ URI uri = manager.getPluginURI();
+ synchronized( prefs )
+ {
+ setURI( "uri", uri );
+ }
+ }
+
+ private class StorageListener implements ModificationListener
+ {
+ public void modified( ModificationEvent event )
+ {
+ RepositoryManager manager = (RepositoryManager)
event.getManager();
+ try
+ {
+ Date date = new Date();
+ setRepositoryManager( manager );
+ manager.setCreationDate( date );
+ }
+ catch( Throwable e )
+ {
+ // TODO: propergate the error up to the HCI
+ manager.getLogger().error( "storage failure", e );
+ }
+ }
+ }
+}
+
+
- svn commit: r2729 - development/main/transit/core/handler/src/main/net/dpml/transit/builder, mcconnell, 06/05/2005
Archive powered by MHonArc 2.6.24.