001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.framework;
016:
017: import java.io.Serializable;
018: import org.araneaframework.InputData;
019: import org.araneaframework.Message;
020: import org.araneaframework.OutputData;
021: import org.araneaframework.framework.filter.StandardMountPointFilterService;
022:
023: /**
024: * This context allows to <i>mount</i> specific pathes, so that when user requests an URI matching this path it would
025: * show him predefined use case. The context uses a message factory instead of any concrete component factory, so that
026: * arbitrary actions could be done on the underlying component hierarchy.
027: * <p>
028: * A typical application of this context would be to generate an URL including the mounted path and pass it to another user.
029: * The other user may then access the particular use case by simply copying the URL into his browser. Note that the URL may be longer
030: * than the mounted path, in that case the suffix will be passed to the message factory and may be used as a parameter.
031: * <p>
032: * As an example consider that we want to mount client use case to the path <code>/mount/clients</code>.
033: * If we now submit an URL <code>http://server/main/mount/clients/3331</code> then
034: * the <code>3331</code> will be passed as the suffix to the message factory and may be used to show the particular client.
035: *
036: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
037: *
038: * @see StandardMountPointFilterService
039: */
040: public interface MountContext extends Serializable {
041: public static final String MOUNT_PATH = "/mount/";
042:
043: /**
044: * Mounts a message factory to the specified URI prefix. All requests to pathes matching this prefix
045: * will cause the {@link MessageFactory} to be called and the built {@link Message} to be sent.
046: * <p>
047: * In case several prefixes match the current path the most specific one will be used.
048: *
049: * @param input Input data representing the current HTTP request.
050: * @param uriPrefix The prefix of the URI that will be matched aginst the current URL.
051: * @param messageFactory The factory that should produce the message used to
052: *
053: * @return The assembled full URL pointing to the mounted path prefix.
054: *
055: * @see #getMountURL(InputData, String)
056: */
057: public String mount(InputData input, String uriPrefix,
058: MessageFactory messageFactory);
059:
060: /**
061: * Unmounts the message factory from the specified URI prefix.
062: *
063: * @param uriPrefix Mounted URI prefix.
064: */
065: public void unmount(String uriPrefix);
066:
067: /**
068: * Returns an assembled full URL pointing to the mounted URI prefix.
069: * URL can be further modified by appending the path or query parameters.
070: *
071: * @param input Input data representing the current HTTP request.
072: * @param uri Mounted URI prefix.
073: * @return The assembled full URL pointing to the mounted path prefix.
074: */
075: public String getMountURL(InputData input, String uri);
076:
077: /**
078: * Returns the {@link Message} that applies the mounted action corresponding to the current URL.
079: * Used primarily by the {@link StandardMountPointFilterService} or similar services to <i>mount</i> the application state
080: * correspondimng to the URL.
081: *
082: * @param input Input data representing the current HTTP request.
083: * @return The {@link Message} corresponding to the current mounted URL or <code>null</code>.
084: */
085: public Message getMountedMessage(InputData input);
086:
087: public interface MessageFactory extends Serializable {
088: /**
089: * Creates a {@link Message} used to update the current component hierarchy in response to the user accessing this specific URL.
090: * A message can for example select a menu item, start a flow or authenticate the user. After the message is applied the framework
091: * will proceed to render the result.
092: *
093: * @param url The full URL accessed by the user.
094: * @param suffix The suffix after the matched mounted path part.
095: * @param input Submitted data.
096: * @param output Response data.
097: * @return Message that will be applied to the component hierarchy.
098: */
099: public Message buildMessage(String url, String suffix,
100: InputData input, OutputData output);
101: }
102: }
|