incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1031386 - in /incubator/isis/trunk: core/runtime/src/main/java/org/apache/isis/runtime/system/installers/ core/webapp/src/main/java/org/apache/isis/webapp/ core/webapp/src/main/java/org/apache/isis/webapp/auth/ core/webapp/src/main/java/or...
Date Fri, 05 Nov 2010 01:11:10 GMT
Author: danhaywood
Date: Fri Nov  5 01:11:10 2010
New Revision: 1031386

URL: http://svn.apache.org/viewvc?rev=1031386&view=rev
Log:
further updates for restful viewer to get support\prototype up-n-running

Added:
    incubator/isis/trunk/support/prototype/viewer-restful/src/main/resources/
Modified:
    incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/system/installers/IsisSystemUsingInstallers.java
    incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/IsisWebAppBootstrapper.java
    incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/WebAppConstants.java
    incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/auth/AuthenticationSessionLookupStrategyDefault.java
    incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/servlets/ResourceServlet.java
    incubator/isis/trunk/support/prototype/viewer-restful/   (props changed)

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/system/installers/IsisSystemUsingInstallers.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/system/installers/IsisSystemUsingInstallers.java?rev=1031386&r1=1031385&r2=1031386&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/system/installers/IsisSystemUsingInstallers.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/system/installers/IsisSystemUsingInstallers.java Fri Nov  5 01:11:10 2010
@@ -17,361 +17,356 @@
  *  under the License.
  */
 
+package org.apache.isis.runtime.system.installers;
 
-package org.apache.isis.runtime.system.installers;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
-import static org.apache.isis.commons.ensure.Ensure.ensureThatState;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.isis.metamodel.config.IsisConfiguration;
-import org.apache.isis.metamodel.specloader.FacetDecoratorInstaller;
-import org.apache.isis.metamodel.specloader.ObjectReflector;
-import org.apache.isis.metamodel.specloader.ObjectReflectorInstaller;
-import org.apache.isis.runtime.authentication.AuthenticationManager;
-import org.apache.isis.runtime.authentication.AuthenticationManagerInstaller;
-import org.apache.isis.runtime.authorization.AuthorizationManager;
-import org.apache.isis.runtime.authorization.AuthorizationManagerInstaller;
-import org.apache.isis.runtime.fixturesinstaller.FixturesInstaller;
-import org.apache.isis.runtime.imageloader.TemplateImageLoader;
-import org.apache.isis.runtime.imageloader.TemplateImageLoaderInstaller;
-import org.apache.isis.runtime.installers.InstallerLookup;
-import org.apache.isis.runtime.persistence.PersistenceMechanismInstaller;
-import org.apache.isis.runtime.persistence.PersistenceSessionFactory;
-import org.apache.isis.runtime.persistence.internal.RuntimeContextFromSession;
-import org.apache.isis.runtime.persistence.services.ServicesInstaller;
-import org.apache.isis.runtime.remoting.ClientConnectionInstaller;
-import org.apache.isis.runtime.session.IsisSessionFactory;
-import org.apache.isis.runtime.session.IsisSessionFactoryDefault;
-import org.apache.isis.runtime.system.DeploymentType;
-import org.apache.isis.runtime.system.IsisSystemException;
-import org.apache.isis.runtime.system.IsisSystemAbstract;
-import org.apache.isis.runtime.system.SystemConstants;
-import org.apache.isis.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller;
-import org.apache.isis.runtime.userprofile.UserProfileLoader;
-import org.apache.isis.runtime.userprofile.UserProfileLoaderDefault;
-import org.apache.isis.runtime.userprofile.UserProfileStore;
-import org.apache.isis.runtime.userprofile.UserProfileStoreInstaller;
-
-
-public class IsisSystemUsingInstallers extends IsisSystemAbstract {
-
-    public static final Logger LOG = Logger.getLogger(IsisSystemUsingInstallers.class);
-
-    private final InstallerLookup installerLookup;
-
-    private AuthenticationManagerInstaller authenticationInstaller;
-    private AuthorizationManagerInstaller authorizationInstaller;
-    private ObjectReflectorInstaller reflectorInstaller;
-    private ServicesInstaller servicesInstaller;
-    private UserProfileStoreInstaller userProfileStoreInstaller;
-    private PersistenceMechanismInstaller persistenceMechanismInstaller;
-    private FixturesInstaller fixtureInstaller;
-
-
-    // ///////////////////////////////////////////
-    // Constructors
-    // ///////////////////////////////////////////
-
-    public IsisSystemUsingInstallers(final DeploymentType deploymentType, final InstallerLookup installerLookup) {
-        super(deploymentType);
-        ensureThatArg(installerLookup, is(not(nullValue())));
-        this.installerLookup = installerLookup;
-    }
-
-    // ///////////////////////////////////////////
-    // InstallerLookup
-    // ///////////////////////////////////////////
-
-    /**
-     * As per {@link #IsisSystemUsingInstallers(DeploymentType, InstallerLookup) constructor}.
-     */
-    public InstallerLookup getInstallerLookup() {
-        return installerLookup;
-    }
-
-    // ///////////////////////////////////////////
-    // Create context hooks
-    // ///////////////////////////////////////////
-
-    public IsisSessionFactory doCreateSessionFactory(final DeploymentType deploymentType)
-            throws IsisSystemException {
-        final PersistenceSessionFactory persistenceSessionFactory = obtainPersistenceSessionFactory(deploymentType);
-        final UserProfileLoader userProfileLoader = new UserProfileLoaderDefault(obtainUserProfileStore());
-        return createSessionFactory(deploymentType, userProfileLoader, persistenceSessionFactory);
-    }
-
-    /**
-     * Overloaded version designed to be called by subclasses that need to explicitly specify different
-     * persistence mechanisms.
-     * 
-     * <p>
-     * This is <i>not</i> a hook method, rather it is designed to be called <i>from</i> the
-     * {@link #doCreateSessionFactory(DeploymentType) hook method}.
-     */
-    protected final IsisSessionFactory createSessionFactory(
-            final DeploymentType deploymentType,
-            final UserProfileLoader userProfileLoader,
-            final PersistenceSessionFactory persistenceSessionFactory) throws IsisSystemException {
-
-        final IsisConfiguration configuration = getConfiguration();
-        final AuthenticationManager authenticationManager = obtainAuthenticationManager(deploymentType);
-        final AuthorizationManager authorizationManager = obtainAuthorizationManager(deploymentType);
-        final TemplateImageLoader templateImageLoader = obtainTemplateImageLoader();
-        final ObjectReflector reflector = obtainReflector(deploymentType);
-        
-        final List<Object> servicesList = obtainServices();
-
-        // bind metamodel to the (runtime) framework
-        // REVIEW: misplaced? seems like a side-effect... 
-        reflector.setRuntimeContext(new RuntimeContextFromSession());
-
-        return new IsisSessionFactoryDefault(deploymentType, configuration, templateImageLoader, reflector,
-                authenticationManager, authorizationManager, userProfileLoader, persistenceSessionFactory, servicesList);
-
-    }
-
-    // ///////////////////////////////////////////
-    // Configuration
-    // ///////////////////////////////////////////
-
-	/**
-     * Returns a <i>snapshot</i> of the {@link IsisConfiguration configuration} held by the
-     * {@link #getInstallerLookup() installer lookup}.
-     * 
-     * @see InstallerLookup#getConfiguration()
-     */
-    @Override
-    public IsisConfiguration getConfiguration() {
-        return installerLookup.getConfiguration();
-    }
-
-    // ///////////////////////////////////////////
-    // Authentication & Authorization
-    // ///////////////////////////////////////////
-
-    public void lookupAndSetAuthenticatorAndAuthorization(DeploymentType deploymentType) {
-
-    	IsisConfiguration configuration = installerLookup.getConfiguration();
-    	String connection = configuration.getString(SystemConstants.CLIENT_CONNECTION_KEY);
-    	
-        if (connection != null) {
-            lookupAndSetAuthenticatorAndAuthorizationUsingClientConnectionInstaller(connection);
-        } else {
-            lookupAndSetAuthenticatorAndAuthorizationInstallers(deploymentType);
-        }
-    }
-
-	private void lookupAndSetAuthenticatorAndAuthorizationUsingClientConnectionInstaller(
-			String connection) {
-		ClientConnectionInstaller clientConnectionInstaller = installerLookup.clientConnectionInstaller(connection);
-		if (clientConnectionInstaller == null) {
-			return;
-		}
-		setAuthenticationInstaller(clientConnectionInstaller);
-		setAuthorizationInstaller(clientConnectionInstaller);
-	}
-
-	private void lookupAndSetAuthenticatorAndAuthorizationInstallers(DeploymentType deploymentType) {
-		// use the one specified in configuration
-		final AuthenticationManagerInstaller authenticationInstaller = installerLookup.authenticationManagerInstaller(null,deploymentType);
-		if (authenticationInstaller != null) {
-		    setAuthenticationInstaller(authenticationInstaller);
-		}
-
-		// use the one specified in configuration
-		final AuthorizationManagerInstaller authorizationInstaller = installerLookup.authorizationManagerInstaller(null, deploymentType);
-		if (authorizationInstaller != null) {
-		    setAuthorizationInstaller(authorizationInstaller);
-		}
-	}
-
-    /**
-     * Set the type of connection to used to access the server.
-     * 
-     * <p>
-     * Note that the {@link IsisSessionFactoryUsingInstallers} also checks the
-     * {@link ClientConnectionInstaller} twice over: to see if a <tt>PersistenceSessionProxy</tt> should be
-     * used as a persistor, and for any {@link FacetDecoratorInstaller}s.
-     */
-    public void setAuthenticationInstaller(final AuthenticationManagerInstaller authenticationManagerInstaller) {
-        this.authenticationInstaller = authenticationManagerInstaller;
-    }
-
-    /**
-     * Set the type of connection to used to access the server.
-     * 
-     * <p>
-     * Note that the {@link IsisSessionFactoryUsingInstallers} also checks the
-     * {@link ClientConnectionInstaller} twice over: to see if a <tt>PersistenceSessionProxy</tt> should be
-     * used as a persistor, and for any {@link FacetDecoratorInstaller}s.
-     */
-    public void setAuthorizationInstaller(final AuthorizationManagerInstaller authorizationManagerInstaller) {
-        this.authorizationInstaller = authorizationManagerInstaller;
-    }
-
-    protected AuthenticationManager obtainAuthenticationManager(DeploymentType deploymentType) {
-        return authenticationInstaller.createAuthenticationManager();
-    }
-    
-    protected AuthorizationManager obtainAuthorizationManager(DeploymentType deploymentType) {
-        return authorizationInstaller.createAuthorizationManager();
-    }
-    
-
-    // ///////////////////////////////////////////
-    // Fixtures
-    // ///////////////////////////////////////////
-
-    public void lookupAndSetFixturesInstaller() {
-        IsisConfiguration configuration = installerLookup.getConfiguration();
-        String fixture = configuration.getString(SystemConstants.FIXTURES_INSTALLER_KEY);
-
-        final FixturesInstaller fixturesInstaller = installerLookup.fixturesInstaller(fixture);
-        if (fixturesInstaller != null) {
-            this.fixtureInstaller = fixturesInstaller;
-        }
-    }
-
-    public void setFixtureInstaller(FixturesInstaller fixtureInstaller) {
-		this.fixtureInstaller = fixtureInstaller;
-	}
-    
-    @Override
-    protected FixturesInstaller obtainFixturesInstaller() throws IsisSystemException {
-        return fixtureInstaller;
-    }
-
-    
-    // ///////////////////////////////////////////
-    // Template Image Loader
-    // ///////////////////////////////////////////
-
-    /**
-     * Uses the {@link TemplateImageLoader} configured in {@link InstallerLookup}, if available, else falls
-     * back to that of the superclass.
-     */
-    @Override
-    protected TemplateImageLoader obtainTemplateImageLoader() {
-        TemplateImageLoaderInstaller templateImageLoaderInstaller = installerLookup.templateImageLoaderInstaller(null);
-        if (templateImageLoaderInstaller != null) {
-            return templateImageLoaderInstaller.createLoader();
-        } else {
-            return super.obtainTemplateImageLoader();
-        }
-    }
-
-    // ///////////////////////////////////////////
-    // Reflector
-    // ///////////////////////////////////////////
-
-    public void setReflectorInstaller(final ObjectReflectorInstaller reflectorInstaller) {
-        this.reflectorInstaller = reflectorInstaller;
-    }
-
-    @Override
-    protected ObjectReflector obtainReflector(DeploymentType deploymentType) throws IsisSystemException {
-        if (reflectorInstaller == null) {
-            String fromCmdLine = getConfiguration().getString(SystemConstants.REFLECTOR_KEY);
-            reflectorInstaller = installerLookup.reflectorInstaller(fromCmdLine);
-        }
-        ensureThatState(reflectorInstaller, is(not(nullValue())),
-                "reflector installer has not been injected and could not be looked up");
-
-        // add in transaction support (if already in set then will be ignored)
-        reflectorInstaller.addFacetDecoratorInstaller(installerLookup
-                .getInstaller(TransactionFacetDecoratorInstaller.class));
-
-        // if there is a client connection installer, then add facet decorator installer also
-        String connection = getConfiguration().getString(SystemConstants.CLIENT_CONNECTION_KEY);
-        if (connection != null) {
-            FacetDecoratorInstaller clientConnectionInstaller = installerLookup.clientConnectionInstaller(connection);
-            reflectorInstaller.addFacetDecoratorInstaller(clientConnectionInstaller);
-        }
-
-        return reflectorInstaller.createReflector();
-    }
-
-    
-    // ///////////////////////////////////////////
-    // Services
-    // ///////////////////////////////////////////
-
-
-    public void setServicesInstaller(ServicesInstaller servicesInstaller) {
-		this.servicesInstaller = servicesInstaller;
-	}
-    
-	@Override
-	protected List<Object> obtainServices() {
-        if (servicesInstaller == null) {
-            servicesInstaller = installerLookup.servicesInstaller(null);
-        }
-        ensureThatState(servicesInstaller, is(not(nullValue())),
-                "services installer has not been injected and could not be looked up");
-
-        return servicesInstaller.getServices(getDeploymentType());
-	}
-
-	
-    // ///////////////////////////////////////////
-    // User Profile Loader/Store
-    // ///////////////////////////////////////////
-    
-
-    public void lookupAndSetUserProfileFactoryInstaller() {
-        IsisConfiguration configuration = installerLookup.getConfiguration();
-        String persistor = configuration.getString(SystemConstants.PROFILE_PERSISTOR_INSTALLER_KEY);
-
-           UserProfileStoreInstaller userProfilePersistenceMechanismInstaller = installerLookup.userProfilePersistenceMechanismInstaller(persistor, getDeploymentType());
-            if (userProfilePersistenceMechanismInstaller != null) {
-                setUserProfileStoreInstaller(userProfilePersistenceMechanismInstaller);
-            }
-        }
-    
-    public void setUserProfileStoreInstaller(UserProfileStoreInstaller userProfilestoreInstaller) {
-        this.userProfileStoreInstaller = userProfilestoreInstaller;
-    }
-    
-	protected UserProfileStore obtainUserProfileStore() {
-		return userProfileStoreInstaller.createUserProfileStore(getConfiguration());
-	}
-    
-
-    // ///////////////////////////////////////////
-    // PersistenceSessionFactory
-    // ///////////////////////////////////////////
-
-    public void setPersistenceMechanismInstaller(final PersistenceMechanismInstaller persistenceMechanismInstaller) {
-        this.persistenceMechanismInstaller = persistenceMechanismInstaller;
-    }
-
-    @Override
-    protected PersistenceSessionFactory obtainPersistenceSessionFactory(DeploymentType deploymentType)
-            throws IsisSystemException {
-
-        // attempt to look up connection (that is, a ProxyPersistor)
-        String connection = getConfiguration().getString(SystemConstants.CLIENT_CONNECTION_KEY);
-        if (connection != null) {
-            persistenceMechanismInstaller = installerLookup.clientConnectionInstaller(connection);
-        }
-        
-        // if nothing, look for a object store persistor
-        if (persistenceMechanismInstaller == null) {
-            String persistenceMechanism = getConfiguration().getString(SystemConstants.OBJECT_PERSISTOR_INSTALLER_KEY);
-            persistenceMechanismInstaller = installerLookup.persistenceMechanismInstaller(persistenceMechanism, deploymentType);
-        }
-        
-        ensureThatState(persistenceMechanismInstaller, is(not(nullValue())),
-                "persistor installer has not been injected and could not be looked up");
-
-        return persistenceMechanismInstaller.createPersistenceSessionFactory(deploymentType);
-    }
-
-
-}
+import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
+import static org.apache.isis.commons.ensure.Ensure.ensureThatState;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import java.util.List;
+
+import org.apache.isis.metamodel.config.IsisConfiguration;
+import org.apache.isis.metamodel.specloader.FacetDecoratorInstaller;
+import org.apache.isis.metamodel.specloader.ObjectReflector;
+import org.apache.isis.metamodel.specloader.ObjectReflectorInstaller;
+import org.apache.isis.runtime.authentication.AuthenticationManager;
+import org.apache.isis.runtime.authentication.AuthenticationManagerInstaller;
+import org.apache.isis.runtime.authorization.AuthorizationManager;
+import org.apache.isis.runtime.authorization.AuthorizationManagerInstaller;
+import org.apache.isis.runtime.fixturesinstaller.FixturesInstaller;
+import org.apache.isis.runtime.imageloader.TemplateImageLoader;
+import org.apache.isis.runtime.imageloader.TemplateImageLoaderInstaller;
+import org.apache.isis.runtime.installers.InstallerLookup;
+import org.apache.isis.runtime.persistence.PersistenceMechanismInstaller;
+import org.apache.isis.runtime.persistence.PersistenceSessionFactory;
+import org.apache.isis.runtime.persistence.internal.RuntimeContextFromSession;
+import org.apache.isis.runtime.persistence.services.ServicesInstaller;
+import org.apache.isis.runtime.remoting.ClientConnectionInstaller;
+import org.apache.isis.runtime.session.IsisSessionFactory;
+import org.apache.isis.runtime.session.IsisSessionFactoryDefault;
+import org.apache.isis.runtime.system.DeploymentType;
+import org.apache.isis.runtime.system.IsisSystemAbstract;
+import org.apache.isis.runtime.system.IsisSystemException;
+import org.apache.isis.runtime.system.SystemConstants;
+import org.apache.isis.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller;
+import org.apache.isis.runtime.userprofile.UserProfileLoader;
+import org.apache.isis.runtime.userprofile.UserProfileLoaderDefault;
+import org.apache.isis.runtime.userprofile.UserProfileStore;
+import org.apache.isis.runtime.userprofile.UserProfileStoreInstaller;
+import org.apache.log4j.Logger;
+
+public class IsisSystemUsingInstallers extends IsisSystemAbstract {
+
+    public static final Logger LOG = Logger.getLogger(IsisSystemUsingInstallers.class);
+
+    private final InstallerLookup installerLookup;
+
+    private AuthenticationManagerInstaller authenticationInstaller;
+    private AuthorizationManagerInstaller authorizationInstaller;
+    private ObjectReflectorInstaller reflectorInstaller;
+    private ServicesInstaller servicesInstaller;
+    private UserProfileStoreInstaller userProfileStoreInstaller;
+    private PersistenceMechanismInstaller persistenceMechanismInstaller;
+    private FixturesInstaller fixtureInstaller;
+
+    // ///////////////////////////////////////////
+    // Constructors
+    // ///////////////////////////////////////////
+
+    public IsisSystemUsingInstallers(final DeploymentType deploymentType, final InstallerLookup installerLookup) {
+        super(deploymentType);
+        ensureThatArg(installerLookup, is(not(nullValue())));
+        this.installerLookup = installerLookup;
+    }
+
+    // ///////////////////////////////////////////
+    // InstallerLookup
+    // ///////////////////////////////////////////
+
+    /**
+     * As per {@link #IsisSystemUsingInstallers(DeploymentType, InstallerLookup) constructor}.
+     */
+    public InstallerLookup getInstallerLookup() {
+        return installerLookup;
+    }
+
+    // ///////////////////////////////////////////
+    // Create context hooks
+    // ///////////////////////////////////////////
+
+    @Override
+    public IsisSessionFactory doCreateSessionFactory(final DeploymentType deploymentType) throws IsisSystemException {
+        final PersistenceSessionFactory persistenceSessionFactory = obtainPersistenceSessionFactory(deploymentType);
+        final UserProfileLoader userProfileLoader = new UserProfileLoaderDefault(obtainUserProfileStore());
+        return createSessionFactory(deploymentType, userProfileLoader, persistenceSessionFactory);
+    }
+
+    /**
+     * Overloaded version designed to be called by subclasses that need to explicitly specify different persistence
+     * mechanisms.
+     * 
+     * <p>
+     * This is <i>not</i> a hook method, rather it is designed to be called <i>from</i> the
+     * {@link #doCreateSessionFactory(DeploymentType) hook method}.
+     */
+    protected final IsisSessionFactory createSessionFactory(final DeploymentType deploymentType,
+        final UserProfileLoader userProfileLoader, final PersistenceSessionFactory persistenceSessionFactory)
+        throws IsisSystemException {
+
+        final IsisConfiguration configuration = getConfiguration();
+        final AuthenticationManager authenticationManager = obtainAuthenticationManager(deploymentType);
+        final AuthorizationManager authorizationManager = obtainAuthorizationManager(deploymentType);
+        final TemplateImageLoader templateImageLoader = obtainTemplateImageLoader();
+        final ObjectReflector reflector = obtainReflector(deploymentType);
+
+        final List<Object> servicesList = obtainServices();
+
+        // bind metamodel to the (runtime) framework
+        // REVIEW: misplaced? seems like a side-effect...
+        reflector.setRuntimeContext(new RuntimeContextFromSession());
+
+        return new IsisSessionFactoryDefault(deploymentType, configuration, templateImageLoader, reflector,
+            authenticationManager, authorizationManager, userProfileLoader, persistenceSessionFactory, servicesList);
+
+    }
+
+    // ///////////////////////////////////////////
+    // Configuration
+    // ///////////////////////////////////////////
+
+    /**
+     * Returns a <i>snapshot</i> of the {@link IsisConfiguration configuration} held by the
+     * {@link #getInstallerLookup() installer lookup}.
+     * 
+     * @see InstallerLookup#getConfiguration()
+     */
+    @Override
+    public IsisConfiguration getConfiguration() {
+        return installerLookup.getConfiguration();
+    }
+
+    // ///////////////////////////////////////////
+    // Authentication & Authorization
+    // ///////////////////////////////////////////
+
+    public void lookupAndSetAuthenticatorAndAuthorization(DeploymentType deploymentType) {
+
+        IsisConfiguration configuration = installerLookup.getConfiguration();
+        String connection = configuration.getString(SystemConstants.CLIENT_CONNECTION_KEY);
+
+        if (connection != null) {
+            lookupAndSetAuthenticatorAndAuthorizationUsingClientConnectionInstaller(connection);
+        } else {
+            lookupAndSetAuthenticatorAndAuthorizationInstallers(deploymentType);
+        }
+    }
+
+    private void lookupAndSetAuthenticatorAndAuthorizationUsingClientConnectionInstaller(String connection) {
+        ClientConnectionInstaller clientConnectionInstaller = installerLookup.clientConnectionInstaller(connection);
+        if (clientConnectionInstaller == null) {
+            return;
+        }
+        setAuthenticationInstaller(clientConnectionInstaller);
+        setAuthorizationInstaller(clientConnectionInstaller);
+    }
+
+    private void lookupAndSetAuthenticatorAndAuthorizationInstallers(DeploymentType deploymentType) {
+        // use the one specified in configuration
+        String authenticationManagerKey = getConfiguration().getString(SystemConstants.AUTHENTICATION_INSTALLER_KEY);
+        final AuthenticationManagerInstaller authenticationInstaller =
+            installerLookup.authenticationManagerInstaller(authenticationManagerKey, deploymentType);
+        if (authenticationInstaller != null) {
+            setAuthenticationInstaller(authenticationInstaller);
+        }
+
+        // use the one specified in configuration
+        String authorizationManagerKey = getConfiguration().getString(SystemConstants.AUTHORIZATION_INSTALLER_KEY);
+        final AuthorizationManagerInstaller authorizationInstaller =
+            installerLookup.authorizationManagerInstaller(authorizationManagerKey, deploymentType);
+        if (authorizationInstaller != null) {
+            setAuthorizationInstaller(authorizationInstaller);
+        }
+    }
+
+    /**
+     * Set the type of connection to used to access the server.
+     * 
+     * <p>
+     * Note that the {@link IsisSessionFactoryUsingInstallers} also checks the {@link ClientConnectionInstaller} twice
+     * over: to see if a <tt>PersistenceSessionProxy</tt> should be used as a persistor, and for any
+     * {@link FacetDecoratorInstaller}s.
+     */
+    public void setAuthenticationInstaller(final AuthenticationManagerInstaller authenticationManagerInstaller) {
+        this.authenticationInstaller = authenticationManagerInstaller;
+    }
+
+    /**
+     * Set the type of connection to used to access the server.
+     * 
+     * <p>
+     * Note that the {@link IsisSessionFactoryUsingInstallers} also checks the {@link ClientConnectionInstaller} twice
+     * over: to see if a <tt>PersistenceSessionProxy</tt> should be used as a persistor, and for any
+     * {@link FacetDecoratorInstaller}s.
+     */
+    public void setAuthorizationInstaller(final AuthorizationManagerInstaller authorizationManagerInstaller) {
+        this.authorizationInstaller = authorizationManagerInstaller;
+    }
+
+    @Override
+    protected AuthenticationManager obtainAuthenticationManager(DeploymentType deploymentType) {
+        return authenticationInstaller.createAuthenticationManager();
+    }
+
+    protected AuthorizationManager obtainAuthorizationManager(DeploymentType deploymentType) {
+        return authorizationInstaller.createAuthorizationManager();
+    }
+
+    // ///////////////////////////////////////////
+    // Fixtures
+    // ///////////////////////////////////////////
+
+    public void lookupAndSetFixturesInstaller() {
+        IsisConfiguration configuration = installerLookup.getConfiguration();
+        String fixture = configuration.getString(SystemConstants.FIXTURES_INSTALLER_KEY);
+
+        final FixturesInstaller fixturesInstaller = installerLookup.fixturesInstaller(fixture);
+        if (fixturesInstaller != null) {
+            this.fixtureInstaller = fixturesInstaller;
+        }
+    }
+
+    public void setFixtureInstaller(FixturesInstaller fixtureInstaller) {
+        this.fixtureInstaller = fixtureInstaller;
+    }
+
+    @Override
+    protected FixturesInstaller obtainFixturesInstaller() throws IsisSystemException {
+        return fixtureInstaller;
+    }
+
+    // ///////////////////////////////////////////
+    // Template Image Loader
+    // ///////////////////////////////////////////
+
+    /**
+     * Uses the {@link TemplateImageLoader} configured in {@link InstallerLookup}, if available, else falls back to that
+     * of the superclass.
+     */
+    @Override
+    protected TemplateImageLoader obtainTemplateImageLoader() {
+        TemplateImageLoaderInstaller templateImageLoaderInstaller = installerLookup.templateImageLoaderInstaller(null);
+        if (templateImageLoaderInstaller != null) {
+            return templateImageLoaderInstaller.createLoader();
+        } else {
+            return super.obtainTemplateImageLoader();
+        }
+    }
+
+    // ///////////////////////////////////////////
+    // Reflector
+    // ///////////////////////////////////////////
+
+    public void setReflectorInstaller(final ObjectReflectorInstaller reflectorInstaller) {
+        this.reflectorInstaller = reflectorInstaller;
+    }
+
+    @Override
+    protected ObjectReflector obtainReflector(DeploymentType deploymentType) throws IsisSystemException {
+        if (reflectorInstaller == null) {
+            String fromCmdLine = getConfiguration().getString(SystemConstants.REFLECTOR_KEY);
+            reflectorInstaller = installerLookup.reflectorInstaller(fromCmdLine);
+        }
+        ensureThatState(reflectorInstaller, is(not(nullValue())),
+            "reflector installer has not been injected and could not be looked up");
+
+        // add in transaction support (if already in set then will be ignored)
+        reflectorInstaller.addFacetDecoratorInstaller(installerLookup
+            .getInstaller(TransactionFacetDecoratorInstaller.class));
+
+        // if there is a client connection installer, then add facet decorator installer also
+        String connection = getConfiguration().getString(SystemConstants.CLIENT_CONNECTION_KEY);
+        if (connection != null) {
+            FacetDecoratorInstaller clientConnectionInstaller = installerLookup.clientConnectionInstaller(connection);
+            reflectorInstaller.addFacetDecoratorInstaller(clientConnectionInstaller);
+        }
+
+        return reflectorInstaller.createReflector();
+    }
+
+    // ///////////////////////////////////////////
+    // Services
+    // ///////////////////////////////////////////
+
+    public void setServicesInstaller(ServicesInstaller servicesInstaller) {
+        this.servicesInstaller = servicesInstaller;
+    }
+
+    @Override
+    protected List<Object> obtainServices() {
+        if (servicesInstaller == null) {
+            servicesInstaller = installerLookup.servicesInstaller(null);
+        }
+        ensureThatState(servicesInstaller, is(not(nullValue())),
+            "services installer has not been injected and could not be looked up");
+
+        return servicesInstaller.getServices(getDeploymentType());
+    }
+
+    // ///////////////////////////////////////////
+    // User Profile Loader/Store
+    // ///////////////////////////////////////////
+
+    public void lookupAndSetUserProfileFactoryInstaller() {
+        IsisConfiguration configuration = installerLookup.getConfiguration();
+        String persistor = configuration.getString(SystemConstants.PROFILE_PERSISTOR_INSTALLER_KEY);
+
+        UserProfileStoreInstaller userProfilePersistenceMechanismInstaller =
+            installerLookup.userProfilePersistenceMechanismInstaller(persistor, getDeploymentType());
+        if (userProfilePersistenceMechanismInstaller != null) {
+            setUserProfileStoreInstaller(userProfilePersistenceMechanismInstaller);
+        }
+    }
+
+    public void setUserProfileStoreInstaller(UserProfileStoreInstaller userProfilestoreInstaller) {
+        this.userProfileStoreInstaller = userProfilestoreInstaller;
+    }
+
+    @Override
+    protected UserProfileStore obtainUserProfileStore() {
+        return userProfileStoreInstaller.createUserProfileStore(getConfiguration());
+    }
+
+    // ///////////////////////////////////////////
+    // PersistenceSessionFactory
+    // ///////////////////////////////////////////
+
+    public void setPersistenceMechanismInstaller(final PersistenceMechanismInstaller persistenceMechanismInstaller) {
+        this.persistenceMechanismInstaller = persistenceMechanismInstaller;
+    }
+
+    @Override
+    protected PersistenceSessionFactory obtainPersistenceSessionFactory(DeploymentType deploymentType)
+        throws IsisSystemException {
+
+        // attempt to look up connection (that is, a ProxyPersistor)
+        String connection = getConfiguration().getString(SystemConstants.CLIENT_CONNECTION_KEY);
+        if (connection != null) {
+            persistenceMechanismInstaller = installerLookup.clientConnectionInstaller(connection);
+        }
+
+        // if nothing, look for a object store persistor
+        if (persistenceMechanismInstaller == null) {
+            String persistenceMechanism = getConfiguration().getString(SystemConstants.OBJECT_PERSISTOR_INSTALLER_KEY);
+            persistenceMechanismInstaller =
+                installerLookup.persistenceMechanismInstaller(persistenceMechanism, deploymentType);
+        }
+
+        ensureThatState(persistenceMechanismInstaller, is(not(nullValue())),
+            "persistor installer has not been injected and could not be looked up");
+
+        return persistenceMechanismInstaller.createPersistenceSessionFactory(deploymentType);
+    }
+
+}

Modified: incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/IsisWebAppBootstrapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/IsisWebAppBootstrapper.java?rev=1031386&r1=1031385&r2=1031386&view=diff
==============================================================================
--- incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/IsisWebAppBootstrapper.java (original)
+++ incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/IsisWebAppBootstrapper.java Fri Nov  5 01:11:10 2010
@@ -66,7 +66,7 @@ public class IsisWebAppBootstrapper impl
     public static IsisSystem getSystemBoundTo(
             ServletContext servletContext) {
         Object system = servletContext
-                .getAttribute(WebAppConstants.NAKED_OBJECTS_SYSTEM_KEY);
+                .getAttribute(WebAppConstants.ISIS_SYSTEM_KEY);
         return (IsisSystem) system;
     }
 
@@ -106,7 +106,7 @@ public class IsisWebAppBootstrapper impl
 
         IsisSystem system = injector.getInstance(IsisSystem.class);
 
-        servletContext.setAttribute(WebAppConstants.NAKED_OBJECTS_SYSTEM_KEY,
+        servletContext.setAttribute(WebAppConstants.ISIS_SYSTEM_KEY,
                 system);
         } catch (RuntimeException e) {
             LOG.error("startup failed", e);
@@ -194,14 +194,14 @@ public class IsisWebAppBootstrapper impl
 
         try {
             final IsisSystem system = (IsisSystem) servletContext
-                    .getAttribute(WebAppConstants.NAKED_OBJECTS_SYSTEM_KEY);
+                    .getAttribute(WebAppConstants.ISIS_SYSTEM_KEY);
             if (system != null) {
                 LOG.info("calling system shutdown");
                 system.shutdown();
             }
         } finally {
             servletContext
-                    .removeAttribute(WebAppConstants.NAKED_OBJECTS_SYSTEM_KEY);
+                    .removeAttribute(WebAppConstants.ISIS_SYSTEM_KEY);
             LOG.info("server shut down");
         }
     }

Modified: incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/WebAppConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/WebAppConstants.java?rev=1031386&r1=1031385&r2=1031386&view=diff
==============================================================================
--- incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/WebAppConstants.java (original)
+++ incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/WebAppConstants.java Fri Nov  5 01:11:10 2010
@@ -53,7 +53,7 @@ public final class WebAppConstants {
 	 * Key under which the {@link IsisSystem} is bound as a
 	 * servlet context attribute (<tt>ServletContext#getAttribute(String)</tt>).
 	 */
-	public final static String NAKED_OBJECTS_SYSTEM_KEY = WebAppConstants.class
+	public final static String ISIS_SYSTEM_KEY = WebAppConstants.class
 			.getPackage().getName()
 			+ ".isisSystem";
 

Modified: incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/auth/AuthenticationSessionLookupStrategyDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/auth/AuthenticationSessionLookupStrategyDefault.java?rev=1031386&r1=1031385&r2=1031386&view=diff
==============================================================================
--- incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/auth/AuthenticationSessionLookupStrategyDefault.java (original)
+++ incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/auth/AuthenticationSessionLookupStrategyDefault.java Fri Nov  5 01:11:10 2010
@@ -17,95 +17,88 @@
  *  under the License.
  */
 
+package org.apache.isis.webapp.auth;
 
-package org.apache.isis.webapp.auth;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.metamodel.authentication.AuthenticationSession;
-import org.apache.isis.runtime.authentication.AuthenticationManager;
-import org.apache.isis.runtime.authentication.standard.exploration.AuthenticationRequestExploration;
-import org.apache.isis.runtime.authentication.standard.fixture.AuthenticationRequestLogonFixture;
-import org.apache.isis.runtime.context.IsisContext;
-import org.apache.isis.runtime.system.IsisSystem;
-import org.apache.isis.webapp.WebAppConstants;
-
-/**
- * Looks up from the {@link HttpSession}, failing
- * that attempts to logon using a {@link LogonFixture} (if available and not
- * already used) or in exploration mode.
- * 
- * <p>
- * The {@link AuthenticationSession} is looked up from the {@link HttpSession} using
- * the value {@value WebAppConstants#HTTP_SESSION_AUTHENTICATION_SESSION_KEY}.
- * Because we only want to use the {@link LogonFixture} once, the {@link HttpSession}
- * also stores the value {@value WebAppConstants#HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY}
- * once a logon has occurred implicitly.
- */
-public class AuthenticationSessionLookupStrategyDefault extends
-		AuthenticationSessionLookupStrategyAbstract {
-
-	public AuthenticationSession lookup(ServletRequest servletRequest,
-			ServletResponse servletResponse) {
-
-		// use previously authenticated session if available.
-		HttpSession httpSession = getHttpSession(servletRequest);
-		AuthenticationSession authSession = (AuthenticationSession) httpSession
-			.getAttribute(WebAppConstants.HTTP_SESSION_AUTHENTICATION_SESSION_KEY);
-		if (authSession != null) {
-			boolean sessionValid = getAuthenticationManager().isSessionValid(authSession);
-			if (sessionValid) {
-				return authSession;
-			}
-		}
-		
-		// otherwise, look for LogonFixture and try to authenticate
-		ServletContext servletContext = getServletContext(servletRequest);
-		IsisSystem system = (IsisSystem) servletContext
-		.getAttribute(WebAppConstants.NAKED_OBJECTS_SYSTEM_KEY);
-		if (system == null) {
-			// not expected to happen...
-			return null;
-		}
-		LogonFixture logonFixture = system.getLogonFixture();
-		
-		// see if exploration is supported
-		if (system.getDeploymentType().isExploring()) {
-			authSession = getAuthenticationManager().authenticate(
-					new AuthenticationRequestExploration(logonFixture));
-			if (authSession != null) {
-				return authSession;
-			}
-		}
-		
-		boolean loggedInUsingLogonFixture = httpSession.getAttribute(WebAppConstants.HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY) != null;
-		if (logonFixture != null && !loggedInUsingLogonFixture) {
-			httpSession.setAttribute(WebAppConstants.HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY, true);
-			return getAuthenticationManager().authenticate(
-					new AuthenticationRequestLogonFixture(logonFixture));
-		}
-
-		return null;
-	}
-
-	public void bind(ServletRequest servletRequest,
-			ServletResponse servletResponse, AuthenticationSession authSession) {
-		HttpSession httpSession = getHttpSession(servletRequest);
-		httpSession.setAttribute(
-				WebAppConstants.HTTP_SESSION_AUTHENTICATION_SESSION_KEY,
-				authSession);
-	}
-
-	// //////////////////////////////////////////////////////////
-	// Dependencies (from context)
-	// //////////////////////////////////////////////////////////
-
-	private static AuthenticationManager getAuthenticationManager() {
-		return IsisContext.getAuthenticationManager();
-	}
-
-}
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.metamodel.authentication.AuthenticationSession;
+import org.apache.isis.runtime.authentication.AuthenticationManager;
+import org.apache.isis.runtime.authentication.standard.exploration.AuthenticationRequestExploration;
+import org.apache.isis.runtime.authentication.standard.fixture.AuthenticationRequestLogonFixture;
+import org.apache.isis.runtime.context.IsisContext;
+import org.apache.isis.runtime.system.IsisSystem;
+import org.apache.isis.webapp.WebAppConstants;
+
+/**
+ * Looks up from the {@link HttpSession}, failing that attempts to logon using a {@link LogonFixture} (if available and
+ * not already used) or in exploration mode.
+ * 
+ * <p>
+ * The {@link AuthenticationSession} is looked up from the {@link HttpSession} using the value
+ * {@value WebAppConstants#HTTP_SESSION_AUTHENTICATION_SESSION_KEY}. Because we only want to use the
+ * {@link LogonFixture} once, the {@link HttpSession} also stores the value
+ * {@value WebAppConstants#HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY} once a logon has occurred
+ * implicitly.
+ */
+public class AuthenticationSessionLookupStrategyDefault extends AuthenticationSessionLookupStrategyAbstract {
+
+    @Override
+    public AuthenticationSession lookup(ServletRequest servletRequest, ServletResponse servletResponse) {
+
+        // use previously authenticated session if available.
+        HttpSession httpSession = getHttpSession(servletRequest);
+        AuthenticationSession authSession =
+            (AuthenticationSession) httpSession.getAttribute(WebAppConstants.HTTP_SESSION_AUTHENTICATION_SESSION_KEY);
+        if (authSession != null) {
+            boolean sessionValid = getAuthenticationManager().isSessionValid(authSession);
+            if (sessionValid) {
+                return authSession;
+            }
+        }
+
+        // otherwise, look for LogonFixture and try to authenticate
+        ServletContext servletContext = getServletContext(servletRequest);
+        IsisSystem system = (IsisSystem) servletContext.getAttribute(WebAppConstants.ISIS_SYSTEM_KEY);
+        if (system == null) {
+            // not expected to happen...
+            return null;
+        }
+        LogonFixture logonFixture = system.getLogonFixture();
+
+        // see if exploration is supported
+        if (system.getDeploymentType().isExploring()) {
+            authSession = getAuthenticationManager().authenticate(new AuthenticationRequestExploration(logonFixture));
+            if (authSession != null) {
+                return authSession;
+            }
+        }
+
+        boolean loggedInUsingLogonFixture =
+            httpSession.getAttribute(WebAppConstants.HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY) != null;
+        if (logonFixture != null && !loggedInUsingLogonFixture) {
+            httpSession.setAttribute(WebAppConstants.HTTP_SESSION_LOGGED_ON_PREVIOUSLY_USING_LOGON_FIXTURE_KEY, true);
+            return getAuthenticationManager().authenticate(new AuthenticationRequestLogonFixture(logonFixture));
+        }
+
+        return null;
+    }
+
+    @Override
+    public void bind(ServletRequest servletRequest, ServletResponse servletResponse, AuthenticationSession authSession) {
+        HttpSession httpSession = getHttpSession(servletRequest);
+        httpSession.setAttribute(WebAppConstants.HTTP_SESSION_AUTHENTICATION_SESSION_KEY, authSession);
+    }
+
+    // //////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // //////////////////////////////////////////////////////////
+
+    private static AuthenticationManager getAuthenticationManager() {
+        return IsisContext.getAuthenticationManager();
+    }
+
+}

Modified: incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/servlets/ResourceServlet.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/servlets/ResourceServlet.java?rev=1031386&r1=1031385&r2=1031386&view=diff
==============================================================================
--- incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/servlets/ResourceServlet.java (original)
+++ incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/servlets/ResourceServlet.java Fri Nov  5 01:11:10 2010
@@ -17,80 +17,80 @@
  *  under the License.
  */
 
+package org.apache.isis.webapp.servlets;
 
-package org.apache.isis.webapp.servlets;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-import org.apache.isis.commons.io.IoUtils;
-import org.apache.isis.commons.lang.Resources;
-import org.apache.isis.commons.lang.StringUtils;
-
-
-/**
- * 
- * @author Dan Haywood
- *
- */
-public class ResourceServlet extends HttpServlet {
-
-    private static final long serialVersionUID = 1L;
-    private final Logger LOG = Logger.getLogger(ResourceServlet.class);
-
-    @Override
-    protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
-            IOException {
-        processRequest(request, response);
-    }
-
-    @Override
-    protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
-            IOException {
-        processRequest(request, response);
-    }
-
-    private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
-            IOException {
-        final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath());
-        LOG.info("request: " + servletPath);
-        
-        // try to load from classpath
-        InputStream is = Resources.getResourceAsStream(servletPath);
-        if (is != null) {
-            IoUtils.copy(is, response.getOutputStream());
-            is.close();
-            return;
-        }
-        
-        // otherwise, try to load from filesystem
-        is = getRealPath(request);
-        if (is != null) {
-            IoUtils.copy(is, response.getOutputStream());
-            is.close();
-            return;
-        }
-        
-        LOG.warn("failed to load resource from classpath or file system: " + servletPath);
-    }
-
-	private FileInputStream getRealPath(final HttpServletRequest request) {
-		String realPath = request.getSession().getServletContext().getRealPath(request.getServletPath());
-		if (realPath == null) {
-		    return null;
-		}
-        try {
-			return new FileInputStream(realPath);
-		} catch (FileNotFoundException e) {
-			return null;
-		}
-	}
-}
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.isis.commons.io.IoUtils;
+import org.apache.isis.commons.lang.Resources;
+import org.apache.isis.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+/**
+ * 
+ * @author Dan Haywood
+ * 
+ */
+public class ResourceServlet extends HttpServlet {
+
+    private static final long serialVersionUID = 1L;
+    private final Logger LOG = Logger.getLogger(ResourceServlet.class);
+
+    @Override
+    protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
+        throws ServletException, IOException {
+        processRequest(request, response);
+    }
+
+    @Override
+    protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
+        IOException {
+        processRequest(request, response);
+    }
+
+    private void processRequest(final HttpServletRequest request, final HttpServletResponse response)
+        throws ServletException, IOException {
+        final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath());
+        LOG.info("request: " + servletPath);
+
+        // try to load from filesystem
+        InputStream is2 = getRealPath(request);
+        if (is2 != null) {
+            LOG.debug("request: " + servletPath + " loaded from filesystem");
+            IoUtils.copy(is2, response.getOutputStream());
+            is2.close();
+            return;
+        }
+
+        // otherwise, try to load from classpath
+        InputStream is = Resources.getResourceAsStream(servletPath);
+        if (is != null) {
+            LOG.debug("request: " + servletPath + " loaded from classpath");
+            IoUtils.copy(is, response.getOutputStream());
+            is.close();
+            return;
+        }
+
+        LOG.warn("failed to load resource from classpath or file system: " + servletPath);
+    }
+
+    private FileInputStream getRealPath(final HttpServletRequest request) {
+        String realPath = request.getSession().getServletContext().getRealPath(request.getServletPath());
+        if (realPath == null) {
+            return null;
+        }
+        try {
+            return new FileInputStream(realPath);
+        } catch (FileNotFoundException e) {
+            return null;
+        }
+    }
+}

Propchange: incubator/isis/trunk/support/prototype/viewer-restful/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov  5 01:11:10 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project



Mime
View raw message