Skip to Content.
Sympa Menu

notify-dpml - r1190 - in trunk/main: metro metro/station/api/src/main/net/dpml/station/info metro/station/builder metro/station/builder/src/main/net/dpml/station/builder metro/station/server metro/station/server/etc/prefs/xmls metro/station/server/src/main/net/dpml/station/server metro/station/server/src/test/net/dpml/station/server transit/core/src/main/net/dpml/part transit/core/src/test/net/dpml

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1190 - in trunk/main: metro metro/station/api/src/main/net/dpml/station/info metro/station/builder metro/station/builder/src/main/net/dpml/station/builder metro/station/server metro/station/server/etc/prefs/xmls metro/station/server/src/main/net/dpml/station/server metro/station/server/src/test/net/dpml/station/server transit/core/src/main/net/dpml/part transit/core/src/test/net/dpml
  • Date: Wed, 15 Mar 2006 19:16:43 +0100

Author: mcconnell
Date: 2006-03-15 19:16:38 +0100 (Wed, 15 Mar 2006)
New Revision: 1190

Added:
trunk/main/metro/station/builder/build.xml

trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryWriter.java
Removed:
trunk/main/transit/core/src/test/net/dpml/lang/
Modified:
trunk/main/metro/module.xml

trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptor.java
trunk/main/metro/station/server/build.xml
trunk/main/metro/station/server/etc/prefs/xmls/registry.xml

trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplicationRegistry.java

trunk/main/metro/station/server/src/test/net/dpml/station/server/RemoteApplicationRegistryTestCase.java
trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
Log:
complete application and registry read/write operations

Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-03-15 16:32:34 UTC (rev 1189)
+++ trunk/main/metro/module.xml 2006-03-15 18:16:38 UTC (rev 1190)
@@ -196,6 +196,9 @@
</project>

<project name="dpml-station-server" basedir="station/server">
+ <properties>
+ <property name="project.test.fork" value="true"/>
+ </properties>
<types>
<type id="jar"/>
<part:plugin class="net.dpml.station.server.StationServerPlugin"/>
@@ -208,7 +211,7 @@
<include ref="dpml/util/dpml-util-cli"/>
</dependencies>
<dependencies scope="test">
- <include ref="junit/junit"/>
+ <include ref="ant/ant-junit"/>
</dependencies>
</project>


Modified:
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptor.java
===================================================================
---
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptor.java
2006-03-15 16:32:34 UTC (rev 1189)
+++
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptor.java
2006-03-15 18:16:38 UTC (rev 1190)
@@ -241,31 +241,4 @@
+ " ]";
}
}
-
- /**
- * Entry bean info.
- */
- public static final class EntryBeanInfo extends SimpleBeanInfo
- {
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Entry.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"key", "applicationDescriptor"} ) );
- return descriptor;
- }
- }
}

Added: trunk/main/metro/station/builder/build.xml
===================================================================
--- trunk/main/metro/station/builder/build.xml 2006-03-15 16:32:34 UTC (rev
1189)
+++ trunk/main/metro/station/builder/build.xml 2006-03-15 18:16:38 UTC (rev
1190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-station-builder" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="dpml:depot" >
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter token="COMMON-XSD-URI" ref="dpml/lang/dpml-common" type="xsd"
feature="uri" />
+ <x:filter token="PART-XSD-URI" ref="dpml/lang/dpml-part" type="xsd"
feature="uri" />
+ <x:filter token="COMPONENT-XSD-URI" ref="dpml/lang/dpml-component"
type="xsd" feature="uri" />
+ <x:filter token="APPLICATION-XSD-URI" ref="dpml/lang/dpml-application"
type="xsd" feature="uri" />
+ </target>
+
+</project>

Added:
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryWriter.java
===================================================================
---
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryWriter.java
2006-03-15 16:32:34 UTC (rev 1189)
+++
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryWriter.java
2006-03-15 18:16:38 UTC (rev 1190)
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2005 Stephen J. 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.station.builder;
+
+import java.net.URI;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Properties;
+
+import net.dpml.station.info.RegistryDescriptor;
+import net.dpml.station.info.RegistryDescriptor.Entry;
+import net.dpml.station.info.ApplicationDescriptor;
+import net.dpml.station.info.StartupPolicy;
+
+import net.dpml.part.DOM3DocumentBuilder;
+
+import net.dpml.lang.BuilderException;
+import net.dpml.lang.Builder;
+
+import net.dpml.transit.info.ValueDirective;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test example application sources.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class RegistryWriter
+{
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String APPLICATION_SCHEMA_URN =
"@APPLICATION-XSD-URI@";
+
+ /**
+ * Externalize the part to XML.
+ * @param part the part to externalize
+ * @param output the output stream
+ * @exception IOException if an IO error occurs
+ */
+ public void writeRegistryDescriptor(
+ RegistryDescriptor descriptor, OutputStream output, String pad )
throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( XML_HEADER );
+ writer.write( "\n" );
+ writer.write( "\n<registry xmlns=\"" + APPLICATION_SCHEMA_URN +
"\">" );
+ writer.write( "\n" );
+
+ Entry[] entries = descriptor.getEntries();
+ for( int i=0; i<entries.length; i++ )
+ {
+ Entry entry = entries[i];
+ writeEntry( writer, entry, " " );
+ }
+ writer.write( "\n" );
+ writer.write( "\n</registry>" );
+ writer.write( "\n" );
+ writer.flush();
+ output.close();
+ }
+
+ private void writeEntry( Writer writer, Entry entry, String pad ) throws
IOException
+ {
+ String key = entry.getKey();
+ ApplicationDescriptor descriptor = entry.getApplicationDescriptor();
+ String title = descriptor.getTitle();
+ StartupPolicy policy = descriptor.getStartupPolicy();
+ String policyValue = policy.getName();
+
+ writer.write( "\n" + pad + "<app key=\"" + key + "\"" );
+ if( null != title )
+ {
+ writer.write( " title=\"" + title + "\"" );
+ }
+ writer.write( " policy=\"" + policyValue + "\">" );
+ writeJvm( writer, descriptor, pad + " " );
+ writeCodebase( writer, descriptor, pad + " " );
+ writer.write( "\n" + pad + "</app>" );
+ writer.write( "\n" );
+ }
+
+ private void writeJvm( Writer writer, ApplicationDescriptor descriptor,
String pad ) throws IOException
+ {
+ writer.write( "\n" + pad + "<jvm" );
+ String base = descriptor.getBasePath();
+ if( null != base )
+ {
+ writer.write( " basedir=\"" + base + "\">" );
+ }
+ else
+ {
+ writer.write( ">" );
+ }
+ int startup = descriptor.getStartupTimeout();
+ int shutdown = descriptor.getShutdownTimeout();
+ writer.write( "\n" + pad + " <startup>" + startup + "</startup>" );
+ writer.write( "\n" + pad + " <shutdown>" + shutdown + "</shutdown>"
);
+ Properties properties = descriptor.getSystemProperties();
+ String[] names = (String[]) properties.keySet().toArray( new
String[0] );
+ if( names.length > 0 )
+ {
+ writer.write( "\n" + pad + " <properties>" );
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ String value = properties.getProperty( name );
+ writer.write( "\n" + pad + " <property name=\"" + name +
"\" value=\"" + value + "\"/>" );
+ }
+ writer.write( "\n" + pad + " </properties>" );
+ }
+ writer.write( "\n" + pad + "</jvm>" );
+ }
+
+ private void writeCodebase( Writer writer, ApplicationDescriptor
descriptor, String pad ) throws IOException
+ {
+ String uri = descriptor.getCodeBaseURISpec();
+ writer.write( "\n" + pad + "<codebase uri=\"" + uri + "\"" );
+ ValueDirective[] values = descriptor.getValueDirectives();
+ if( values.length == 0 )
+ {
+ writer.write( "/>" );
+ }
+ else
+ {
+ writeValueDirectives( writer, values, pad + " " );
+ writer.write( "\n" + pad + "</codebase>" );
+ }
+ }
+
+ protected void writeValueDirectives( Writer writer, ValueDirective[]
values, String pad ) throws IOException
+ {
+ for( int i=0; i<values.length; i++ )
+ {
+ ValueDirective value = values[i];
+ writeValueDirective( writer, value, pad );
+ }
+ }
+
+ protected void writeValueDirective( Writer writer, ValueDirective value,
String pad ) throws IOException
+ {
+ String method = value.getMethodName();
+ String target = value.getTargetExpression();
+
+ writer.write( "\n" + pad + "<param" );
+ if( null != target )
+ {
+ writer.write( " class=\"" + target + "\"" );
+ }
+ if( null != method )
+ {
+ writer.write( " method=\"" + method + "\"" );
+ }
+ if( value.isCompound() )
+ {
+ writer.write( ">" );
+ ValueDirective[] values = value.getValueDirectives();
+ writeValueDirectives( writer, values, pad + " " );
+ writer.write( "\n" + pad + "</param>" );
+ }
+ else
+ {
+ String v = value.getBaseValue();
+ if( null != value )
+ {
+ writer.write( " value=\"" + v + "\"" );
+ }
+ writer.write( "/>" );
+ }
+ }
+}

Modified: trunk/main/metro/station/server/build.xml
===================================================================
--- trunk/main/metro/station/server/build.xml 2006-03-15 16:32:34 UTC (rev
1189)
+++ trunk/main/metro/station/server/build.xml 2006-03-15 18:16:38 UTC (rev
1190)
@@ -6,6 +6,10 @@

<transit:import uri="local:template:dpml/tools/standard"/>

+ <target name="init" depends="standard.init">
+ <x:filter token="APPLICATION-XSD-URI" ref="dpml/lang/dpml-application"
type="xsd" feature="uri" />
+ </target>
+
<target name="build" depends="standard.build">
<rmic base="${project.target.classes.main.dir}"
classpathref="project.compile.path">
<include name="**/RemoteApplicationRegistry.class"/>

Modified: trunk/main/metro/station/server/etc/prefs/xmls/registry.xml
===================================================================
--- trunk/main/metro/station/server/etc/prefs/xmls/registry.xml 2006-03-15
16:32:34 UTC (rev 1189)
+++ trunk/main/metro/station/server/etc/prefs/xmls/registry.xml 2006-03-15
18:16:38 UTC (rev 1190)
@@ -1,30 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.4.0" class="java.beans.XMLDecoder">
- <object class="net.dpml.station.info.RegistryDescriptor">
- <array class="net.dpml.station.info.RegistryDescriptor$Entry" length="1">
- <void index="0">
- <object class="net.dpml.station.info.RegistryDescriptor$Entry">
- <string>demo</string>
- <object class="net.dpml.station.info.ApplicationDescriptor">
- <string>link:part:dpml/planet/http/dpml-http-server</string>
- <string>demo</string>
- <array class="net.dpml.transit.info.ValueDirective" length="0"/>
- <string>${dpml.data}/work</string>
- <object class="net.dpml.station.info.StartupPolicy" method="parse">
- <string>manual</string>
- </object>
- <int>6</int>
- <int>6</int>
- <object class="java.util.Properties">
- <void method="put">
- <string>java.util.logging.config.class</string>
- <string>net.dpml.depot.DepotLoggingConfiguration</string>
- </void>
- </object>
- <null/>
- </object>
- </object>
- </void>
- </array>
- </object>
-</java>
+
+<registry xmlns="@APPLICATION-XSD-URI@">
+
+ <app key="demo" title="Test Application" policy="manual">
+
+ <jvm>
+ <startup>6</startup>
+ <shutdown>6</shutdown>
+ <properties>
+ <property name="java.util.logging.config.class"
value="net.dpml.depot.DepotLoggingConfiguration"/>
+ </properties>
+ </jvm>
+
+ <codebase uri="link:part:dpml/planet/http/dpml-http-server"/>
+
+ </app>
+
+</registry>

Modified:
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplicationRegistry.java
===================================================================
---
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplicationRegistry.java
2006-03-15 16:32:34 UTC (rev 1189)
+++
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplicationRegistry.java
2006-03-15 18:16:38 UTC (rev 1190)
@@ -42,6 +42,7 @@
import net.dpml.station.RegistryEvent;
import net.dpml.station.RegistryListener;
import net.dpml.station.builder.RegistryBuilder;
+import net.dpml.station.builder.RegistryWriter;
import net.dpml.station.info.StartupPolicy;
import net.dpml.station.info.ApplicationDescriptor;
import net.dpml.station.info.RegistryDescriptor;
@@ -260,8 +261,19 @@
return;
}

- throw new UnsupportedOperationException( "flush" );
-
+ File file = File.createTempFile( "dpml-station", ".xml" );
+ getLogger().info( "writing to temp file: " + file );
+ file.createNewFile();
+ FileOutputStream output = new FileOutputStream( file );
+ Entry[] entries = getEntries();
+ RegistryDescriptor descriptor = new RegistryDescriptor( entries
);
+ RegistryWriter writer = new RegistryWriter();
+ writer.writeRegistryDescriptor( descriptor, output, "" );
+ FileInputStream input = new FileInputStream( file );
+ OutputStream dest = m_url.openConnection().getOutputStream();
+ StreamUtils.copyStream( input, dest, true );
+ getLogger().debug( "updated registry: " + m_url );
+
/*
ClassLoader current =
Thread.currentThread().getContextClassLoader();
ClassLoader context = StartupPolicy.class.getClassLoader();
@@ -395,25 +407,34 @@
{
return new RegistryDescriptor( new Entry[0] );
}
-
- RegistryBuilder builder = new RegistryBuilder();
- Object object = builder.build( new URI( url.toString() ) );
- if( object instanceof RegistryDescriptor )
+ else
{
- return (RegistryDescriptor) object;
+ RegistryBuilder builder = new RegistryBuilder();
+ try
+ {
+ Object object = builder.build( new URI( url.toString() ) );
+ if( object instanceof RegistryDescriptor )
+ {
+ return (RegistryDescriptor) object;
+ }
+ else
+ {
+ final String error =
+ "The object returned from the uri ["
+ + url
+ + "] of the class ["
+ + object.getClass().getName()
+ + "] is not an instance of "
+ + RegistryDescriptor.class.getName()
+ + ".";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ catch( FileNotFoundException e )
+ {
+ return new RegistryDescriptor( new Entry[0] );
+ }
}
- else
- {
- final String error =
- "The object returned from the uri ["
- + url
- + "] of the class ["
- + object.getClass().getName()
- + "] is not an instance of "
- + RegistryDescriptor.class.getName()
- + ".";
- throw new IllegalArgumentException( error );
- }
}

private void processRegistryEvent( RegistryEvent event )

Modified:
trunk/main/metro/station/server/src/test/net/dpml/station/server/RemoteApplicationRegistryTestCase.java
===================================================================
---
trunk/main/metro/station/server/src/test/net/dpml/station/server/RemoteApplicationRegistryTestCase.java
2006-03-15 16:32:34 UTC (rev 1189)
+++
trunk/main/metro/station/server/src/test/net/dpml/station/server/RemoteApplicationRegistryTestCase.java
2006-03-15 18:16:38 UTC (rev 1190)
@@ -30,6 +30,7 @@
import net.dpml.station.RegistryEvent;

import net.dpml.transit.Artifact;
+import net.dpml.transit.Transit;
import net.dpml.transit.Logger;
import net.dpml.transit.info.ValueDirective;
import net.dpml.transit.monitor.LoggingAdapter;
@@ -46,6 +47,11 @@
*/
public class RemoteApplicationRegistryTestCase extends TestCase
{
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ }
+
private URL m_url;
private Logger m_logger = new LoggingAdapter( "registry" );


Modified:
trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
2006-03-15 16:32:34 UTC (rev 1189)
+++ trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
2006-03-15 18:16:38 UTC (rev 1190)
@@ -30,6 +30,7 @@
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.FileNotFoundException;

import javax.xml.XMLConstants;
import javax.xml.validation.Validator;
@@ -114,6 +115,10 @@

return builder.parse( input );
}
+ catch( FileNotFoundException e )
+ {
+ throw e;
+ }
catch( Throwable e )
{
final String error =




  • r1190 - in trunk/main: metro metro/station/api/src/main/net/dpml/station/info metro/station/builder metro/station/builder/src/main/net/dpml/station/builder metro/station/server metro/station/server/etc/prefs/xmls metro/station/server/src/main/net/dpml/station/server metro/station/server/src/test/net/dpml/station/server transit/core/src/main/net/dpml/part transit/core/src/test/net/dpml, mcconnell at BerliOS, 03/15/2006

Archive powered by MHonArc 2.6.24.

Top of Page