notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2827 - in development/main/depot: console/src/main/net/dpml/depot console/src/main/net/dpml/depot/lang station/src/main/net/dpml/depot/station test/brazil/src/main/net/dpml/test
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2827 - in development/main/depot: console/src/main/net/dpml/depot console/src/main/net/dpml/depot/lang station/src/main/net/dpml/depot/station test/brazil/src/main/net/dpml/test
- Date: Sun, 12 Jun 2005 09:09:38 -0400
Author: mcconnell AT dpml.net
Date: Sun Jun 12 09:09:36 2005
New Revision: 2827
Added:
development/main/depot/console/src/main/net/dpml/depot/lang/DepotRMIClassLoaderSpi.java
Modified:
development/main/depot/console/src/main/net/dpml/depot/Main.java
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
development/main/depot/station/src/main/net/dpml/depot/station/StationStorage.java
development/main/depot/test/brazil/src/main/net/dpml/test/Client.java
Log:
more on activation profiles
Modified: development/main/depot/console/src/main/net/dpml/depot/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/Main.java Sun
Jun 12 09:09:36 2005
@@ -244,9 +244,18 @@
{
String id = profile.getID();
registry.bind( id, (Remote) object );
- logger.info(
- "service bound to " + connection.getHost()
- + ":" + connection.getPort() + "/" + id );
+ if( null == connection.getHost() )
+ {
+ logger.info(
+ "service bound to "
+ + connection.getPort() + "/" + id );
+ }
+ else
+ {
+ logger.info(
+ "service bound to " + connection.getHost()
+ + ":" + connection.getPort() + "/" + id );
+ }
}
else if( object instanceof Runnable )
{
@@ -604,6 +613,7 @@
static
{
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
System.setProperty( "java.util.logging.manager",
"net.dpml.depot.logging.LoggingManager" );
System.setProperty( "java.util.logging.manager.altclassloader",
"net.dpml.depot.logging.LoggingManager" );
System.setProperty( "java.util.logging.config.class",
"net.dpml.depot.logging.ConfigurationHandler" );
Added:
development/main/depot/console/src/main/net/dpml/depot/lang/DepotRMIClassLoaderSpi.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/lang/DepotRMIClassLoaderSpi.java
Sun Jun 12 09:09:36 2005
@@ -0,0 +1,191 @@
+/*
+ * 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.depot.lang;
+
+import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.adapter.LoggingAdapter;
+
+/**
+ * The DepotRMIClassLoaderSpi handles the loading of classes that are based
on
+ * plugin artifact types.
+ */
+public class DepotRMIClassLoaderSpi extends RMIClassLoaderSpi
+{
+ private RMIClassLoaderSpi m_delegate =
+ RMIClassLoader.getDefaultProviderInstance();
+
+ private Logger m_logger = setupLogger();
+
+ /**
+ * Provides the implementation for
+ * {@link RMIClassLoader#loadClass(URL,String)},
+ * {@link RMIClassLoader#loadClass(String,String)}, and
+ * {@link RMIClassLoader#loadClass(String,String,ClassLoader)}.
+ *
+ * Loads a class from a codebase URL path, optionally using the
+ * supplied loader.
+ *
+ * @param codebase the list of URLs (separated by spaces) to load
+ * the class from, or <code>null</code>
+ * @param name the name of the class to load
+ * @param defaultLoader additional contextual class loader
+ * to use, or <code>null</code>
+ * @return the <code>Class</code> object representing the loaded class
+ * @throws MalformedURLException if <code>codebase</code> is
+ * non-<code>null</code> and contains an invalid URL, or
+ * if <code>codebase</code> is <code>null</code> and the system
+ * property <code>java.rmi.server.codebase</code> contains an
+ * invalid URL
+ * @throws ClassNotFoundException if a definition for the class
+ * could not be found at the specified location
+ */
+ public Class loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ if( null != codebase )
+ {
+ getLogger().info( "Loading: " + name );
+ }
+ return m_delegate.loadClass( codebase, name, defaultLoader );
+ }
+
+ /**
+ * Provides the implementation for
+ * {@link RMIClassLoader#loadProxyClass(String,String[],ClassLoader)}.
+ *
+ * Loads a dynamic proxy class (see {@link java.lang.reflect.Proxy}
+ * that implements a set of interfaces with the given names
+ * from a codebase URL path, optionally using the supplied loader.
+ *
+ * <p>An implementation of this method must either return a proxy
+ * class that implements the named interfaces or throw an exception.
+ *
+ * @param codebase the list of URLs (space-separated) to load
+ * classes from, or <code>null</code>
+ *
+ * @param interfaces the names of the interfaces for the proxy class
+ * to implement
+ *
+ * @return a dynamic proxy class that implements the named interfaces
+ *
+ * @param defaultLoader additional contextual class loader
+ * to use, or <code>null</code>
+ *
+ * @throws MalformedURLException if <code>codebase</code> is
+ * non-<code>null</code> and contains an invalid URL, or
+ * if <code>codebase</code> is <code>null</code> and the system
+ * property <code>java.rmi.server.codebase</code> contains an
+ * invalid URL
+ *
+ * @throws ClassNotFoundException if a definition for one of
+ * the named interfaces could not be found at the specified location,
+ * or if creation of the dynamic proxy class failed (such as if
+ * {@link java.lang.reflect.Proxy#getProxyClass(ClassLoader,Class[])}
+ * would throw an <code>IllegalArgumentException</code> for the given
+ * interface list)
+ */
+ public Class loadProxyClass(String codebase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ if( null != codebase )
+ {
+ getLogger().info( "Loading proxy: " + codebase );
+ }
+ return m_delegate.loadProxyClass( codebase, interfaces,
defaultLoader );
+ }
+
+ /**
+ * Provides the implementation for
+ * {@link RMIClassLoader#getClassLoader(String)}.
+ *
+ * Returns a class loader that loads classes from the given codebase
+ * URL path.
+ *
+ * <p>If there is a security manger, its <code>checkPermission</code>
+ * method will be invoked with a
+ * <code>RuntimePermission("getClassLoader")</code> permission;
+ * this could result in a <code>SecurityException</code>.
+ * The implementation of this method may also perform further security
+ * checks to verify that the calling context has permission to connect
+ * to all of the URLs in the codebase URL path.
+ *
+ * @param codebase the list of URLs (space-separated) from which
+ * the returned class loader will load classes from, or <code>null</code>
+ *
+ * @return a class loader that loads classes from the given codebase URL
+ * path
+ *
+ * @throws MalformedURLException if <code>codebase</code> is
+ * non-<code>null</code> and contains an invalid URL, or
+ * if <code>codebase</code> is <code>null</code> and the system
+ * property <code>java.rmi.server.codebase</code> contains an
+ * invalid URL
+ *
+ * @throws SecurityException if there is a security manager and the
+ * invocation of its <code>checkPermission</code> method fails, or
+ * if the caller does not have permission to connect to all of the
+ * URLs in the codebase URL path
+ */
+ public ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ if( null != codebase )
+ {
+ getLogger().info( "getClassLoader: " + codebase );
+ }
+ return m_delegate.getClassLoader( codebase );
+ }
+
+ /**
+ * Provides the implementation for
+ * {@link RMIClassLoader#getClassAnnotation(Class)}.
+ *
+ * Returns the annotation string (representing a location for
+ * the class definition) that RMI will use to annotate the class
+ * descriptor when marshalling objects of the given class.
+ *
+ * @param cl the class to obtain the annotation for
+ *
+ * @return a string to be used to annotate the given class when
+ * it gets marshalled, or <code>null</code>
+ *
+ * @throws NullPointerException if <code>cl</code> is <code>null</code>
+ */
+ public String getClassAnnotation(Class cl)
+ {
+ return m_delegate.getClassAnnotation( cl );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private static Logger setupLogger()
+ {
+ return new LoggingAdapter( java.util.logging.Logger.getLogger(
"depot" ) );
+ }
+}
Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
Sun Jun 12 09:09:36 2005
@@ -79,9 +79,16 @@
Preferences prefs, Logger logger, Date creation, boolean policy )
throws ProfileException
{
+ if( false == ( "entries".equals( prefs.name() ) ) )
+ {
+ throw new IllegalArgumentException( "prefs" );
+ }
try
{
+ logger.info( "Listing tree: " + prefs );
+ prefs.exportSubtree( System.out );
String[] names = prefs.childrenNames();
+ logger.info( "Station Entry Count: " + names.length );
CodeBaseProfile[] profiles = new CodeBaseProfile[ names.length ];
for( int i=0; i<names.length; i++ )
{
@@ -105,7 +112,7 @@
}
return profiles;
}
- catch( BackingStoreException e )
+ catch( Exception e )
{
final String error =
"Internal error while resolving a persistent activation
group.";
Modified:
development/main/depot/station/src/main/net/dpml/depot/station/StationStorage.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/StationStorage.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/StationStorage.java
Sun Jun 12 09:09:36 2005
@@ -55,17 +55,22 @@
super( prefs, logger, creation, policy );
Properties properties = getProperties();
- CodeBaseProfile[] profiles = getCodeBaseProfiles();
+
+ // TODO: replace the bootstrap profile creation stuff with a
+ // retreval of preferences from a file
+
+ setupBootstrapProfiles();
+ CodeBaseProfile[] profiles = getCodeBaseProfiles( prefs.node(
"entries" ) );
m_profile = new StationProfile( logger, creation, this, properties,
profiles );
}
- protected CodeBaseProfile[] getCodeBaseProfiles()
+ private CodeBaseProfile[] getCodeBaseProfiles( Preferences prefs )
throws ProfileException
{
Logger logger = getLogger();
Date creation = getCreationDate();
boolean policy = getStoragePolicy();
- Preferences prefs = getPreferences().node( "entries" );
+ logger.info( "Station Entries: " + prefs );
return ActivationGroupStorage.getCodeBaseProfiles( prefs, logger,
creation, policy );
}
@@ -134,4 +139,20 @@
{
throw new UnsupportedOperationException( "store/1" );
}
+
+ private void setupBootstrapProfiles() throws ProfileException
+ {
+ setupMexicoProfile();
+ }
+
+ private void setupMexicoProfile() throws ProfileException
+ {
+ String id = "mexico";
+ Date creation = getCreationDate();
+ Logger logger = getLogger().getChildLogger( id );
+ boolean policy = getStoragePolicy();
+ Preferences prefs = getPreferences().node( "entries" ).node( id );
+ prefs.put( "classname", "net.dpml.test.mexico.Server" );
+ prefs.put( "uri", "artifact:jar:dpml/test/dpml-test-mexico#SNAPSHOT"
);
+ }
}
Modified:
development/main/depot/test/brazil/src/main/net/dpml/test/Client.java
==============================================================================
--- development/main/depot/test/brazil/src/main/net/dpml/test/Client.java
(original)
+++ development/main/depot/test/brazil/src/main/net/dpml/test/Client.java
Sun Jun 12 09:09:36 2005
@@ -5,37 +5,35 @@
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import net.dpml.test.mexico.Server;
+import net.dpml.test.mexico.Service;
import net.dpml.test.mexico.Listener;
import net.dpml.test.mexico.Event;
import net.dpml.test.mexico.ClientListener;
public class Client
{
- private Logger m_logger = Logger.getLogger( "brazil" );
-
- public Client( )
+ public Client( ) throws Exception
{
+ Registry registry = LocateRegistry.getRegistry();
+ String[] names = registry.list();
+ for( int i=0; i<names.length; i++ )
+ {
+ System.out.println( "REG: " + names[i] );
+ }
+
+ Service service = (Service) registry.lookup( "mexico" );
+ ClientListener listener = new ClientListener();
+ service.addListener( listener );
try
{
- Registry reg = LocateRegistry.getRegistry();
- Server server = (Server) reg.lookup( "mexico" );
- ClientListener listener = new ClientListener();
- server.addListener( listener );
- server.info();
- server.removeListener( listener );
+ service.info();
}
- catch( Throwable e )
+ catch( RemoteException e )
{
- getLogger().log( Level.SEVERE, "woops", e );
+ System.out.println( "REMOTE EXCEPTION" );
+ throw e;
}
- }
-
- private Logger getLogger()
- {
- return m_logger;
+ service.removeListener( listener );
}
}
- svn commit: r2827 - in development/main/depot: console/src/main/net/dpml/depot console/src/main/net/dpml/depot/lang station/src/main/net/dpml/depot/station test/brazil/src/main/net/dpml/test, mcconnell, 06/12/2005
Archive powered by MHonArc 2.6.24.