Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2806 - development/main/depot/console/src/main/net/dpml/depot/profile

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2806 - development/main/depot/console/src/main/net/dpml/depot/profile
  • Date: Wed, 08 Jun 2005 22:05:11 -0400

Author: mcconnell AT dpml.net
Date: Wed Jun 8 22:05:10 2005
New Revision: 2806

Added:

development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java

development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfileStorage.java

development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfileStorage.java
Log:


Added:
development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java
Wed Jun 8 22:05:10 2005
@@ -0,0 +1,109 @@
+/*
+ * 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.depot.profile;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.Properties;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.management.Home;
+import net.dpml.transit.management.ModificationEvent;
+import net.dpml.transit.builder.AbstractStorageUnit;
+
+import net.dpml.depot.profile.Profile.Connection;
+
+/**
+ * A ProfileHome maintains a persistent application profile.
+ */
+public abstract class AbstractPluginProfileStorage extends ProfileStorage
+{
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ public AbstractPluginProfileStorage(
+ Preferences prefs, Logger logger, Date creation, boolean policy )
+ throws ProfileException
+ {
+ super( prefs, logger, creation, policy );
+ }
+
+ //
------------------------------------------------------------------------
+ // ModificationListener
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ if( getStoragePolicy() )
+ {
+ try
+ {
+ PluginProfile manager = (PluginProfile) event.getManager();
+ Date date = new Date();
+ store( manager );
+ manager.setCreationDate( date );
+ }
+ catch( Throwable e )
+ {
+ getLogger().error( "storage failure", e );
+ }
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // utils
+ //
------------------------------------------------------------------------
+
+ protected URI getPluginURI() throws ProfileException
+ {
+ Preferences prefs = getPreferences();
+ String path = prefs.get( "plugin", null );
+ if( null != path )
+ {
+ try
+ {
+ return new URI( path );
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Plugin application profile contains an invalid uri value."
+ + "\nURI: " + path;
+ throw new ProfileException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Requested plugin profile '" + prefs
+ + "' does not declare a plugin uri attribute.";
+ throw new ProfileException( error );
+ }
+ }
+
+ protected abstract void store( PluginProfile profile );
+}

Added:
development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfileStorage.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfileStorage.java
Wed Jun 8 22:05:10 2005
@@ -0,0 +1,141 @@
+/*
+ * 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.depot.profile;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.Properties;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.management.Home;
+import net.dpml.transit.management.ModificationEvent;
+import net.dpml.transit.builder.AbstractStorageUnit;
+
+import net.dpml.depot.profile.Profile.Connection;
+
+/**
+ * A ProfileHome maintains a persistent application profile.
+ */
+public class BootstrapProfileStorage extends ProfileStorage
+{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ private final BootstrapProfile m_profile;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ public BootstrapProfileStorage(
+ Preferences prefs, Logger logger, Date creation, boolean policy )
+ throws ProfileException
+ {
+ super( prefs, logger, creation, policy );
+
+ String id = super.getID();
+ String title = super.getTitle();
+ Properties properties = super.getProperties();
+ Connection connection = super.getConnection();
+ boolean command = getCommandPolicy();
+
+ String classname = prefs.get( "classname", null );
+ if( null != classname )
+ {
+ String[] classpath = getClasspath();
+ m_profile =
+ new BootstrapProfile(
+ logger, creation, this, id, title, properties, command,
+ connection, classname, classpath );
+ }
+ else
+ {
+ final String error =
+ "Requested profile '" + prefs
+ + "' does not declare either a classname attribute.";
+ throw new ProfileException( error );
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // ModificationListener
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ if( getStoragePolicy() )
+ {
+ try
+ {
+ BootstrapProfile manager = (BootstrapProfile)
event.getManager();
+ Date date = new Date();
+ store( manager );
+ manager.setCreationDate( date );
+ }
+ catch( Throwable e )
+ {
+ getLogger().error( "storage failure", e );
+ }
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // utils
+ //
------------------------------------------------------------------------
+
+ protected Profile getProfile()
+ {
+ return m_profile;
+ }
+
+ private String[] getClasspath() throws ProfileException
+ {
+ Preferences prefs = getPreferences().node( "classpath" );
+ try
+ {
+ String[] keys = prefs.keys();
+ String[] values = new String[ keys.length ];
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ values[i] = prefs.get( key, null );
+ }
+ return values;
+ }
+ catch( BackingStoreException e )
+ {
+ final String error =
+ "Cannot construct a classpath due to non-availability of the
preferences store.";
+ throw new ProfileException( error, e );
+ }
+ }
+
+ protected void store( BootstrapProfile profile )
+ {
+ throw new UnsupportedOperationException( "store/1" );
+ }
+}
\ No newline at end of file

Added:
development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfileStorage.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfileStorage.java
Wed Jun 8 22:05:10 2005
@@ -0,0 +1,138 @@
+/*
+ * 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.depot.profile;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.Properties;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.management.Home;
+import net.dpml.transit.management.ModificationEvent;
+import net.dpml.transit.builder.AbstractStorageUnit;
+
+import net.dpml.depot.profile.Profile.Connection;
+
+/**
+ * A ProfileHome maintains a persistent application profile.
+ */
+public class PluginProfileStorage extends ProfileStorage
+{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ private final PluginProfile m_profile;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ public PluginProfileStorage(
+ Preferences prefs, Logger logger, Date creation, boolean policy )
+ throws ProfileException
+ {
+ super( prefs, logger, creation, policy );
+
+ String id = getID();
+ String title = getTitle();
+ Properties properties = getProperties();
+ Connection connection = getConnection();
+ boolean command = getCommandPolicy();
+ URI uri = getPluginURI();
+ m_profile =
+ new PluginProfile(
+ logger, creation, this, id, title, properties, command,
connection, uri );
+ }
+
+ //
------------------------------------------------------------------------
+ // ModificationListener
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ if( getStoragePolicy() )
+ {
+ try
+ {
+ PluginProfile manager = (PluginProfile) event.getManager();
+ Date date = new Date();
+ store( manager );
+ manager.setCreationDate( date );
+ }
+ catch( Throwable e )
+ {
+ getLogger().error( "storage failure", e );
+ }
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // utils
+ //
------------------------------------------------------------------------
+
+ protected Profile getProfile()
+ {
+ return getPluginProfile();
+ }
+
+ protected PluginProfile getPluginProfile()
+ {
+ return m_profile;
+ }
+
+ protected URI getPluginURI() throws ProfileException
+ {
+ Preferences prefs = getPreferences();
+ String path = prefs.get( "plugin", null );
+ if( null != path )
+ {
+ try
+ {
+ return new URI( path );
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Plugin application profile contains an invalid uri value."
+ + "\nURI: " + path;
+ throw new ProfileException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Requested plugin profile '" + prefs
+ + "' does not declare a plugin uri attribute.";
+ throw new ProfileException( error );
+ }
+ }
+
+ protected void store( PluginProfile profile )
+ {
+ throw new UnsupportedOperationException( "store/1" );
+ }
+}



  • svn commit: r2806 - development/main/depot/console/src/main/net/dpml/depot/profile, mcconnell, 06/08/2005

Archive powered by MHonArc 2.6.24.

Top of Page