01: package org.obe.event;
02:
03: import java.util.Properties;
04: import java.util.Map;
05: import org.obe.spi.event.ApplicationEvent;
06: import org.obe.spi.service.ServiceManager;
07: import org.obe.client.api.repository.RepositoryException;
08:
09: /**
10: * Provides support for classifying Java objects by MIME media type.
11: *
12: * @author Adrian Price
13: */
14: public interface ContentHandler {
15: /**
16: * Initializes the content handler.
17: */
18: void init(ServiceManager svcMgr, Properties props);
19:
20: /**
21: * Returns the full MIME type/subtype for an object's class and content.
22: *
23: * @param data The object to classify.
24: * @return The MIME media type.
25: * @throws RepositoryException
26: */
27: String getContentType(Object data) throws RepositoryException;
28:
29: /**
30: * Wraps an arbitrary Java object into one or more application events. The
31: * handler may process the object in various ways including converting it to
32: * a different type (e.g., from an XML string to an XML document), or
33: * splitting it up into separate sub-objects (e.g., bursting a MIME
34: * multipart message into its constituent body parts).
35: *
36: * @param data Raw event data.
37: * @param attrs Attributes describing the raw event data. Optional.
38: * @param contentType The full MIME type/subtype as determined by a prior
39: * call to {@link #getContentType(Object)}.
40: * @return One or more application events.
41: * @throws RepositoryException
42: */
43: ApplicationEvent[] process(Object data, Map attrs,
44: String contentType) throws RepositoryException;
45: }
|