You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/08/23 12:15:09 UTC

svn commit: r568917 - in /incubator/servicemix/branches/servicemix-4.0: ./ api/ api/src/main/java/org/apache/servicemix/api/ api/src/main/java/org/apache/servicemix/api/support/ api/src/test/java/org/apache/servicemix/api/ core/ core/src/ core/src/main...

Author: gnodet
Date: Thu Aug 23 03:15:05 2007
New Revision: 568917

URL: http://svn.apache.org/viewvc?rev=568917&view=rev
Log:
Add contentType / contentEncoding to Message, add javadocs

Added:
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/EndpointConstants.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Pattern.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Role.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/ServiceMixException.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Status.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Type.java
    incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/OsgiExample.java
    incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/PipelineEndpoint.java
    incubator/servicemix/branches/servicemix-4.0/core/
    incubator/servicemix/branches/servicemix-4.0/core/pom.xml
    incubator/servicemix/branches/servicemix-4.0/core/src/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/AbstractEndpoint.java
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ExchangeImpl.java
    incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/MessageImpl.java
    incubator/servicemix/branches/servicemix-4.0/core/src/test/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/ExchangeImplTest.java
    incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/MessageImplTest.java
Removed:
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/support/
Modified:
    incubator/servicemix/branches/servicemix-4.0/api/pom.xml
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Channel.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Endpoint.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Exchange.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Message.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Reference.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Registry.java
    incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/package.html
    incubator/servicemix/branches/servicemix-4.0/pom.xml

Modified: incubator/servicemix/branches/servicemix-4.0/api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/pom.xml?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/pom.xml Thu Aug 23 03:15:05 2007
@@ -33,6 +33,21 @@
   <version>4.0-SNAPSHOT</version>
   <name>org.apache.servicemix.api</name>
 
+  <dependencies>
+	<dependency>
+	  <groupId>junit</groupId>
+	  <artifactId>junit</artifactId>
+	  <version>4.3.1</version>
+	  <scope>test</scope>
+	</dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>0.9.0-incubator-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Channel.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Channel.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Channel.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Channel.java Thu Aug 23 03:15:05 2007
@@ -16,63 +16,55 @@
  */
 package org.apache.servicemix.api;
 
-import java.util.concurrent.Future;
-
 /**
- * Creates a channel to perform invocations on the NMR.
+ * Creates a channel to perform invocations through the NMR.
+ * Channels are created by the {@link Registry}.  They are used
+ * by {@link Endpoint}s to communicate with the NMR, but they
+ * can also be used by external clients.  In such a case, the
+ * Channel must be closed using the {@link #close()} method
+ * after use.
  *
+ * @see org.apache.servicemix.api.Registry#createChannel()
  * @version $Revision: $
  * @since 4.0
  */
 public interface Channel {
 
     /**
-     * Used for asynchronous notification of the exchange processing being complete
-     *
-     * @version $Revision: $
-     */
-    public interface AsyncHandler {
-
-        void handle(Exchange exchange);
-
-    }
-
-    /**
      * Creates a new exchange.
      *
      * @param pattern specify the InOnly / InOut / RobustInOnly / RobustInOut
      * @return a new exchange of the given pattern
      */
-    Exchange createExchange(Exchange.Pattern pattern);
+    Exchange createExchange(Pattern pattern);
 
     /**
-     * Synchronously invocation of the service
+     * An asynchronous invocation of the service
+     *
+     * @param exchange the exchange to send
      */
-    void invoke(Exchange exchange);
+    void send(Exchange exchange);
 
     /**
-     * An asynchronous invocation of the service which will notify the returned future when the invocation
-     * is complete
+     * Synchronously send the exchange, blocking until the exchange is returned.
      *
-     * @param exchange
-     * @return a future to be invoked with the exchange when it is complete
+     * @param exchange the exchange to send
+     * @return <code>true</code> if the exchange has been processed succesfully
      */
-    Future<Exchange> invokeAsync(Exchange exchange);
+    boolean sendSync(Exchange exchange);
 
     /**
-     * An asynchronous invocation of the service which will invoke the handler when the invocation
-     * is completed
-     *
-     * @param exchange the exchange to invoke
-     * @param handler the handler invoked, typically from another thread, when the invocation is completed
-     * to avoid a thread context switch
-     *
-     * @return a future so that the invocation can be canceled
+     * Synchronously send the exchange
+     * @param exchange the exchange to send
+     * @param timeout time to wait in milliseconds
+     * @return <code>true</code> if the exchange has been processed succesfully
      */
-    Future<Exchange> invokeAsync(Exchange exchange, AsyncHandler handler);
+    boolean sendSync(Exchange exchange, long timeout);
 
     /**
-     * Closes the channel, freeing up any resources (like sockets, threads etc)
+     * Closes the channel, freeing up any resources (like sockets, threads etc).
+     * Channel that are injected onto Endpoints will be closed automatically by
+     * the NMR.
      */
     void close();
 

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Endpoint.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Endpoint.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Endpoint.java Thu Aug 23 03:15:05 2007
@@ -32,7 +32,10 @@
      * Set the channel so that the endpoint can send exchanges back
      * when they are processed or act as a consumer itself.
      * This method will be called by the NMR while the endpoint is registered.
+     * Such a channel does not need to be closed as the NMR will close it
+     * automatically when the endpoint is unregistered.
      *
+     * @see Registry#register(Endpoint, java.util.Map)
      * @param channel the channel that this endpoint can use
      */
     void setChannel(Channel channel);
@@ -40,7 +43,7 @@
     /**
      * Process the given exchange.  The processing can occur in the current thread
      * or asynchronously.
-     * If an exchange has sent an exchange asynchronously to another endpoint,
+     * If an endpoint has sent an exchange asynchronously to another endpoint,
      * it will receive the exchange back using this method.  An endpoint can
      * recognized such exchanges by checking the role of the exchange.
      *

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/EndpointConstants.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/EndpointConstants.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/EndpointConstants.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/EndpointConstants.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * Various constants used for endpoints metadata.
+ * These constants are used when registering an endpoint using
+ * the {@link Registry#register(Endpoint, java.util.Map)}. The given
+ * map contains the metadata associated with the endpoint.
+ *
+ * @version $Revision: $
+ * @since 4.0
+ */
+public interface EndpointConstants {
+
+    String ID = "ID";
+
+    String SERVICE_NAME = "SERVICE_NAME";
+
+    String ENDPOINT_NAME = "ENDPOINT_NAME";
+    
+    String WSDL_URL = "WSDL_URL";
+}

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Exchange.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Exchange.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Exchange.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Exchange.java Thu Aug 23 03:15:05 2007
@@ -16,8 +16,9 @@
  */
 package org.apache.servicemix.api;
 
+import javax.xml.namespace.QName;
 import java.io.Serializable;
-import java.util.Set;
+import java.util.Map;
 
 /**
  * Represents a message exchange.
@@ -26,57 +27,70 @@
  * representing a link to a logical endpoint.
  * Exchanges are created using the {@link Channel}.
  *
+ * TODO: transactions
+ *
  * @version $Revision: $
  * @since 4.0
  */
-public interface Exchange extends Serializable, Cloneable {
+public interface Exchange extends Serializable {
+
+    /**
+     * The unique id of this exchange
+     * @return
+     */
+    String getId();
 
-    enum Pattern {
-        InOnly,
-        RobustInOnly,
-        InOut,
-        InOptionalOut;
-
-        public boolean has(Message.Type msg) {
-            switch (msg) {
-                case In:
-                    return true;
-                case Out:
-                    return this == InOut || this == InOptionalOut;
-                case Fault:
-                    return this != InOnly;
-                default:
-                    return false;
-            }
-        }
-    }
-
-    enum Role {
-        Consumer,
-        Provider,
-    }
+    /**
+     * The exchange pattern
+     * @return
+     */
+    Pattern getPattern();
 
     /**
      * The role of the exchange.
      * @return
      */
     Role getRole();
-
+    
     /**
-     * The exchange pattern
+     * The status of the exchange
      * @return
      */
-    Exchange.Pattern getPattern();
+    Status getStatus();
 
-    Reference getTarget();
+    /**
+     * Set the status of the exchange
+     *
+     * @param status the new status
+     */
+    void setStatus(Status status);
 
+    /**
+     * The target used for this exchange
+     * @return
+     */
+    Reference getTarget();
+    
+    /**
+     * The target used for this exchange
+     *
+     * @param target the target endpoint
+     */
     void setTarget(Reference target);
 
     /**
+     * The service operation of this exchange
      *
-     * @return the names of properties set on this exchange
+     * @return  the operation
      */
-    Set<String> getPropertyNames();
+    QName getOperation();
+
+    /**
+     * The service operation of this exchange
+     *
+     * @param operation the operation
+     */
+    void setOperation(QName operation);
 
     /**
      * Get a given property by its name.
@@ -84,7 +98,34 @@
      * @param name the name of the property to retrieve
      * @return the value of the property or <code>null</code> if none has been set
      */
-    Object      getProperty(String name);
+    Object getProperty(String name);
+
+    /**
+     * Get a typed property.
+     *
+     * @param type the type of the property to retrieve
+     * @return the value of the property or <code>null</code> if none has been set
+     */
+    <T> T getProperty(Class<T> type);
+
+    /**
+     * Returns a property associated with this exchange by name and specifying
+     * the type required
+     *
+     * @param name the name of the property
+     * @param type the type of the property
+     * @return the value of the given header or null if there is no property for
+     *         the given name or null if it cannot be converted to the given
+     *         type
+     */
+    <T> T getProperty(String name, Class<T> type);
+
+    /**
+     * Return all the properties associated with this exchange
+     *
+     * @return all the properties
+     */
+    Map<String, Object> getProperties();
 
     /**
      * Set a property on this exchange.
@@ -93,52 +134,120 @@
      * @param name the name of the property
      * @param value the value for this property or <code>null</code>
      */
-    void        setProperty(String name, Object value);
+    void setProperty(String name, Object value);
 
     /**
-     * Obtains the input message
-     * @return the input message or <code>null</code> if
-     *         this pattern do not have any
+     * Set a typed property on this exchange.
+     *
+     * @param type the key
+     * @param value the value
+     */
+    <T> void setProperty(Class<T> type, T value);
+
+    /**
+     * Obtains the input message, lazily creating one if none
+     * has been associated with this exchange. If you want to inspect this property
+     * but not force lazy creation then invoke the {@link #getIn(boolean)}
+     * method passing in false
+     *
+     * @return the input message
      */
     Message getIn();
 
     /**
-     * Obtains the output message
-     * @return the output message or <code>null</code> if
-     *         this pattern does not have any
+     * Returns the inbound message, optionally creating one if one has not already
+     * been associated with this exchange.
+     *
+     * @param lazyCreate <code>true</code> if the message should be created
+     * @return the input message
+     */
+    Message getIn(boolean lazyCreate);
+    
+    /**
+     * Obtains the outbound message, lazily creating one if none
+     * has been associated with this exchange and if this exchange
+     * supports an out message. If you want to inspect this property
+     * but not force lazy creation then invoke the {@link #getOut(boolean)}
+     * method passing in false
+     *
+     * @return the output message
      */
     Message getOut();
 
     /**
-     * Obtains the fault message
-     * @return the fault message or <code>null</code> if
-     *         this pattern does not have any
+     * Returns the outbound message, optionally creating one if one has not already
+     * been associated with this exchange
+     *
+     * @return the out message
+     */
+    Message getOut(boolean lazyCreate);
+
+    /**
+     * Obtains the fault message, lazily creating one if none
+     * has been associated with this exchange and if this exchange
+     * supports a faut message. If you want to inspect this property
+     * but not force lazy creation then invoke the {@link #getFault(boolean)}
+     * method passing in false
+     *
+     * @return the fault message
      */
     Message getFault();
 
     /**
-     * Obtains the message of the given type
+     * Returns the fault message, optionally creating one if one has not already
+     * been associated with this exchange
+     *
+     * @return the fault message
+     */
+    Message getFault(boolean lazyCreate);
+
+    /**
+     * Obtains the given message, lazily creating one if none
+     * has been associated with this exchange and if this exchange
+     * supports a faut message. If you want to inspect this property
+     * but not force lazy creation then invoke the {@link #getMessage(Type, boolean)}
+     * method passing in false
+     *
+     * @param type the type of message to retrieve
      * @return the message or <code>null</code> if
      *         this pattern does not support this type of message
      */
-    Message getMessage(Message.Type dir);
+    Message getMessage(Type type);
+
+    /**
+     * Returns the message of the given type, optionally creating one if one has not already
+     * been associated with this exchange
+     *
+     * @param type the type of message to retrieve
+     * @return the given message
+     */
+    Message getMessage(Type type, boolean lazyCreate);
 
     /**
      * Obtains the error of this exchange
+     *
      * @return the exception that caused the exchange to fail
      */
     Exception getError();
 
     /**
+     * Set the error on this exchange
+     *
+     * @param error the exception that caused the exchange to fail
+     */
+    void setError(Exception error);
+
+    /**
      * Make sure that all streams contained in the content and in
      * attachments are transformed to re-readable sources.
      * This method will be called by the framework when persisting
      * the exchange or when displaying it
      */
-    void        ensureReReadable();
+    void ensureReReadable();
 
-    void     copyFrom(Exchange exchange);
+    void copyFrom(Exchange exchange);
     Exchange copy();
-    String   display(boolean displayContent);
+    String display(boolean displayContent);
+
 
 }

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Message.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Message.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Message.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Message.java Thu Aug 23 03:15:05 2007
@@ -17,41 +17,172 @@
 package org.apache.servicemix.api;
 
 import java.io.Serializable;
-import java.util.Set;
+import java.util.Map;
 
 /**
+ * The Message represents the content of a request, a response or a fault.
+ * Messages are part of {@link Exchange}s are created using
+ * {@link Exchange#getIn()}, {@link Exchange#getOut()} and {@link Exchange#getFault()}.
+ *
+ * If the Exchange has to go to a remote ServiceMix instance to be processed
+ * (if the instance is part of a cluster), all headers, attachments and content
+ * have to be Serializable.
+ *
+ * TODO: security
+ *
  * @version $Revision: $
  * @since 4.0
  */
-public interface Message extends Serializable, Cloneable {
+public interface Message extends Serializable {
 
-    enum Type {
-        In, Out, Fault
-    }
-
-    Object      getContent();
-    void        setContent(Object content);
-
-    Set<String> getPropertyNames();
-    Object      getProperty(String name);
-    void        setProperty(String name, Object value);
-
-    Set<String> getAttachmentIds();
-    Object      getAttachment(String id);
-    void        addAttachment(String id, Object value);
-    void        removeAttachment(String id);
+    /**
+     * Get a header on this message.
+     *
+     * @param name the name of the header
+     * @return the value of the header of <code>null</code> if none has been set
+     */
+    Object getHeader(String name);
+
+    /**
+     * Get a typed header.
+     * This is equivalent to:
+     *   <code>exchange.getHeader(type.getName())</code>
+     *
+     * @param type the type of the header
+     * @return the header
+     */
+    <T> T getHeader(Class<T> type);
+
+    /**
+     * Get a header, converting it to the desired type
+     *
+     * @param name the name of the header
+     * @param type the desired type
+     * @return the converted header or <code>null</code> if
+     *          no header has been set or if it can not be transformed
+     *          to the desired type
+     */
+    <T> T getHeader(String name, Class<T> type);
+
+    /**
+     * Set a header for this message
+     * @param name the name of the header
+     * @param value the value of the header
+     */
+    void setHeader(String name, Object value);
+
+    /**
+     * Set a typed header for this message.
+     * This is equivalent to:
+     *   <code>exchange.setHeader(type.getName(), value)</code>
+     *
+     *
+     * @param type the type of the header
+     * @param value the value of the header
+     */
+    <T> void setHeader(Class<T> type, T value);
+
+    /**
+     * Get a map of all the headers for this message
+     *
+     * @return a map of headers
+     */
+    Map<String, Object> getHeaders();
+
+    /**
+     * Retrieve an attachment given its id.
+     *
+     * @param id the id of the attachment to retrieve
+     * @return the attachement or <code>null</code> if none exists
+     */
+    Object getAttachment(String id);
+
+    /**
+     * Add an attachment to this message
+     *
+     * @param id the id of the attachment
+     * @param value the attachment to add
+     */
+    void addAttachment(String id, Object value);
+
+    /**
+     * Remove an attachment on this message
+     *
+     * @param id the id of the attachment to remove
+     */
+    void removeAttachment(String id);
 
     /**
+     * Retrieve a map of all attachments
      *
+     * @return the map of attachments
+     */
+    Map<String, Object> getAttachments();
+
+    /**
+     * Returns the content of the message in its default format.
+     *
+     * @return the main content of this message
+     */
+    Object getContent();
+
+    /**
+     * Returns the content as the specified type.
+     *
+     * @param type the type in which the content is to be transformed
+     * @return the transformed content
+     */
+    <T> T getContent(Class<T> type);
+
+    /**
+     * Set the content of the message
+     *
+     * @param content the content of the message
+     */
+    void setContent(Object content);
+
+    /**
+     * Get the mime content type describing the content of the message
+     *
+     * @return the mime content type
+     */
+    String getContentType();
+
+    /**
+     * Set the mime content type describing the content of the message
+     *
+     * @param type the mime content type
+     */
+    void setContentType(String type);
+
+    /**
+     * Get the encoding of the message
+     *
+     * @return the encoding
+     */
+    String getContentEncoding();
+
+    /**
+     * Set the encoding of the message
+     *
+     * @param encoding the encoding
+     */
+    void setContentEncoding(String encoding);
+
+    /**
+     * Copies the contents of the other message into this message
+     * 
      * @param msg the message to copy from
      */
-    void        copyFrom(Message msg);
+    void copyFrom(Message msg);
 
     /**
-     * Creates
-     * @return
+     * Creates a copy of this message so that it can
+     * be used and possibly modified further in another exchange
+     * 
+     * @return a new message instance copied from this message
      */
-    Message     copy();
+    Message copy();
 
     /**
      * Make sure that all streams contained in the content and in

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Pattern.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Pattern.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Pattern.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Pattern.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * Pattern of the exchange
+ * 
+ * @version $Revision: $
+ * @since 4.0
+ */
+public enum Pattern {
+    InOnly,
+    RobustInOnly,
+    InOut,
+    InOptionalOut,
+}
\ No newline at end of file

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Reference.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Reference.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Reference.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Reference.java Thu Aug 23 03:15:05 2007
@@ -21,7 +21,8 @@
 /**
  * Represents an endpoint reference or a logical endpoint.
  * References are usually obtained from the {@link Registry} and used
- * as targets for {@link Exchange}s.
+ * as targets for {@link Exchange}s using the {@link Exchange#setTarget(Reference)}
+ * method.
  *
  * @version $Revision: $
  * @since 4.0

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Registry.java?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Registry.java (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Registry.java Thu Aug 23 03:15:05 2007
@@ -24,6 +24,7 @@
  * The Registry is used to register endpoints, unregister them, query endpoints
  * and create a Channel to interfact with them.
  *
+ * @version $Revision: $
  * @since 4.0
  */
 public interface Registry {
@@ -31,9 +32,12 @@
     /**
      * Register the given endpoint in the registry.
      * In an OSGi world, this would be performed automatically by a ServiceTracker.
+     * Upon registration, a {@link Channel} will be injected onto the Endpoint using
+     * the {@link Endpoint#setChannel(Channel)} method.
      *
+     * @see EndpointConstants
      * @param endpoint the endpoint to register
-     * @param properties
+     * @param properties the metadata associated with this endpoint
      */
     void register(Endpoint endpoint, Map<String, ?> properties);
 
@@ -56,8 +60,8 @@
 
     /**
      * This methods creates a Reference from its xml representation.
-     * See {@link Reference.toXml}
-     * 
+     *
+     * @see Reference#toXml()
      * @param xml
      * @return
      */
@@ -65,8 +69,9 @@
 
     /**
      * Create a channel to interact with the NMR without exposing an endpoint.
-     * @return
+     * @return a channel
      */
     Channel createChannel();
 
 }
+

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Role.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Role.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Role.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Role.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * The role of the component processing this exchange.
+ * The role identifies wether the component is the Consumer of the service or the Provider of the service.
+ * 
+ * @version $Revision: $
+ * @since 4.0
+ */
+public enum Role {
+    Consumer,
+    Provider,
+}
\ No newline at end of file

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/ServiceMixException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/ServiceMixException.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/ServiceMixException.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/ServiceMixException.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * Base class for ServiceMix exception
+ * 
+ * @version $Revision: $
+ * @since 4.0
+ */
+public class ServiceMixException extends RuntimeException {
+
+	/**
+	 * Generated serial version UID
+	 */
+	private static final long serialVersionUID = -4589808461481157493L;
+
+	public ServiceMixException() {
+	}
+
+	public ServiceMixException(String message) {
+		super(message);
+	}
+
+	public ServiceMixException(Throwable cause) {
+		super(cause);
+	}
+
+	public ServiceMixException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+}

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Status.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Status.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Status.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Status.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * `The status of the exchange can be Active, Done or Error.
+ * 
+ * @version $Revision: $
+ * @since 4.0
+ */
+public enum Status {
+    Active, 
+    Done, 
+    Error,
+}
\ No newline at end of file

Added: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Type.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Type.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Type.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/Type.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * The type of a message, which can be In, Out or Fault.
+ * 
+ * @version $Revision: $
+ * @since 4.0
+ */
+public enum Type {
+    In,
+    Out,
+    Fault
+}
\ No newline at end of file

Modified: incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/package.html
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/package.html?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/package.html (original)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/main/java/org/apache/servicemix/api/package.html Thu Aug 23 03:15:05 2007
@@ -19,7 +19,7 @@
 </head>
 <body>
 
-Defines the core NMR and its client side invocation API
+Defines the core NMR and its client side invocation API.
 
 </body>
 </html>

Added: incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/OsgiExample.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/OsgiExample.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/OsgiExample.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/OsgiExample.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+import javax.xml.namespace.QName;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+public class OsgiExample {
+
+    public static class MyEndpoint implements Endpoint {
+
+        private Channel channel;
+
+        public void setChannel(Channel channel) {
+            this.channel = channel;
+        }
+
+        public void process(Exchange exchange) {
+            // TODO
+        }
+    }
+
+
+    public void testRegisteringAnEndpoint() {
+        BundleContext bundleContext = null;
+        
+        // registering an endpoint
+        Endpoint e = new MyEndpoint();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(EndpointConstants.ID, "my-endpoint");
+        props.put(EndpointConstants.SERVICE_NAME, new QName("urn:namesapce", "service"));
+        props.put(EndpointConstants.ENDPOINT_NAME, "foo");
+        props.put(EndpointConstants.WSDL_URL, "file:my.wsdl");
+
+        bundleContext.registerService(Endpoint.class.getName(), e, props);
+    }
+
+    public void testFindRegistry() {
+        BundleContext bundleContext = null;
+
+        ServiceReference ref = bundleContext.getServiceReference(Registry.class.getName());
+        Registry reg = (Registry) bundleContext.getService(ref);
+    }
+
+    public void testLookupReference() throws InvalidSyntaxException {
+        Registry reg = null;
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(EndpointConstants.ID, "myEndpoint");
+        Reference target = reg.lookup(props);
+    }
+
+    public void testSendExchange() {
+        Registry reg = null;
+        Reference target = null;
+
+        Channel channel = reg.createChannel();
+        try {
+            Exchange e = channel.createExchange(Pattern.InOnly);
+            e.setTarget(target);
+            e.getIn().setContent("Hello");
+            channel.send(e);
+        } finally {
+            channel.close();
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/PipelineEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/PipelineEndpoint.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/PipelineEndpoint.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/api/src/test/java/org/apache/servicemix/api/PipelineEndpoint.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.api;
+
+/**
+ * @version $Revision: $
+ */
+public class PipelineEndpoint implements Endpoint {
+
+    private Channel channel;
+
+    private Reference transformer;
+    private Reference target;
+
+    public void setChannel(Channel channel) {
+        this.channel = channel;
+    }
+
+    public void setTransformer(Reference transformer) {
+        this.transformer = transformer;
+    }
+
+    public void setTarget(Reference target) {
+        this.target = target;
+    }
+
+    public void process(Exchange exchange) {
+        if (exchange.getPattern() != Pattern.InOnly && exchange.getPattern() != Pattern.RobustInOnly) {
+            fail(exchange, new UnsupportedOperationException("Use an InOnly or RobustInOnly MEP"));
+            return;
+        }
+        Exchange tme = channel.createExchange(Pattern.InOut);
+        tme.setTarget(target);
+        tme.getIn().copyFrom(exchange.getIn());
+        if (!channel.sendSync(tme)) {
+            fail(exchange, new InterruptedException("Timeout"));
+            return;
+        }
+        if (tme.getStatus() == Status.Error) {
+            fail(exchange, tme.getError());
+        } else if (tme.getStatus() == Status.Active && tme.getFault(false) != null) {
+            // TODO: send fault back to the consumer or send it to target or another target?
+            if (exchange.getPattern() == Pattern.InOnly) {
+                // TODO: send fault back as an error or just log them?
+            } else  {
+                exchange.getFault().copyFrom(tme.getFault());
+                done(tme);
+                channel.sendSync(exchange);
+            }
+        } else if (tme.getStatus() == Status.Active && tme.getOut(false) != null) {
+            Exchange me = channel.createExchange(Pattern.InOnly);
+            me.getIn().copyFrom(tme.getOut());
+            boolean res = channel.sendSync(me);
+            done(tme);
+            if (!res) {
+                fail(exchange, new InterruptedException("Timeout"));
+            } else if (me.getStatus() == Status.Done) {
+                done(exchange);
+            } else if (me.getStatus() == Status.Error) {
+                fail(exchange, me.getError());
+            } else if (me.getFault(false) != null) {
+                if (exchange.getPattern() == Pattern.InOnly) {
+                    // TODO: send fault back as an error or just log them?
+                } else  {
+                    exchange.getFault().copyFrom(me.getFault());
+                    done(me);
+                    channel.sendSync(exchange);
+                }
+            } else {
+                fail(exchange, new IllegalStateException()); // This should never happen
+            }
+        } else {
+            fail(exchange, new IllegalStateException()); // This should never happen
+        }
+    }
+
+    private void done(Exchange exchange) {
+        exchange.setStatus(Status.Done);
+        channel.send(exchange);
+    }
+
+
+    private void fail(Exchange exchange, Exception e) {
+        exchange.setError(e);
+        channel.send(exchange);
+    }
+}

Added: incubator/servicemix/branches/servicemix-4.0/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/pom.xml?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/pom.xml (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/pom.xml Thu Aug 23 03:15:05 2007
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicemix</groupId>
+    <artifactId>servicemix</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.servicemix</groupId>
+  <artifactId>org.apache.servicemix.core</artifactId>
+  <packaging>jar</packaging>
+  <version>4.0-SNAPSHOT</version>
+  <name>org.apache.servicemix.core</name>
+
+  <dependencies>
+	<dependency>
+	  <groupId>org.apache.servicemix</groupId>
+	  <artifactId>org.apache.servicemix.api</artifactId>
+	  <version>${project.version}</version>
+	</dependency>
+	<dependency>
+	  <groupId>junit</groupId>
+	  <artifactId>junit</artifactId>
+	  <version>4.3.1</version>
+	  <scope>test</scope>
+	</dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Export-Package>${pom.artifactId}</Export-Package>
+            <DynamicImport-Package>*</DynamicImport-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/AbstractEndpoint.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/AbstractEndpoint.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/AbstractEndpoint.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.core;
+
+import org.apache.servicemix.api.Endpoint;
+import org.apache.servicemix.api.Channel;
+
+/**
+ * @version $Revision: $
+ * @since 4.0
+ */
+public abstract class AbstractEndpoint implements Endpoint {
+
+    private Channel channel;
+
+    public Channel getChannel() {
+        return this.channel;
+    }
+
+    public void setChannel(Channel channel) {
+        this.channel = channel;
+    }
+
+}

Added: incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ExchangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ExchangeImpl.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ExchangeImpl.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ExchangeImpl.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.core;
+
+import org.apache.servicemix.api.Exchange;
+import org.apache.servicemix.api.Message;
+import org.apache.servicemix.api.Pattern;
+import org.apache.servicemix.api.Reference;
+import org.apache.servicemix.api.Role;
+import org.apache.servicemix.api.Status;
+import org.apache.servicemix.api.Type;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * @version $Revision: $
+ * @since 4.0
+ */
+public class ExchangeImpl implements Exchange {
+
+	/**
+	 * Generated serial version UID 
+	 */
+	private static final long serialVersionUID = 5453128544624717320L;
+	
+	private String id;
+	private Status status;
+    private Role role;
+    private Pattern pattern;
+    private Reference target;
+    private QName operation;
+    private Map<String, Object> properties;
+    private Message in;
+    private Message out;
+    private Message fault;
+    private Exception error;
+
+    /**
+     * Creates and exchange of the given pattern
+     * @param pattern the pattern of this exchange
+     */
+    public ExchangeImpl(Pattern pattern) {
+        this.pattern = pattern;
+        this.id = UUID.randomUUID().toString();
+    }
+    
+    private ExchangeImpl() {
+    }
+
+    /**
+     * The unique id of the exchange
+     *
+     * @return the unique id
+     */
+    public String getId() {
+    	return id;
+    }
+
+    /**
+     * The role of the exchange.
+     *
+     * @return the role
+     */
+    public Role getRole() {
+        return role;
+    }
+
+    public void setRole(Role role) {
+        this.role = role;
+    }
+    
+    /**
+     * The status of the exchange
+     * 
+     * @return the status
+     */
+    public Status getStatus() {
+    	return status;
+    }
+
+    public void setStatus(Status status) {
+        this.status = status;
+    }
+
+    /**
+     * The exchange pattern
+     *
+     * @return the pattern
+     */
+    public Pattern getPattern() {
+        return pattern;
+    }
+
+    /**
+     * The target reference
+     * 
+     * @return the target
+     */
+	public Reference getTarget() {
+		return target;
+	}
+
+	/**
+	 * Set the target reference
+	 * 
+	 * @param target the new target
+	 */
+	public void setTarget(Reference target) {
+		this.target = target;
+	}
+
+    /**
+     * The operation
+     *
+     * @return the operation
+     */
+    public QName getOperation() {
+        return operation;
+    }
+
+    /**
+     * Set the operation
+     *
+     * @param operation the operation
+     */
+    public void setOperation(QName operation) {
+        this.operation = operation;
+    }
+
+    /**
+     * Get a given property by its name.
+     *
+     * @param name the name of the property to retrieve
+     * @return the value of the property or <code>null</code> if none has been set
+     */
+    public Object getProperty(String name) {
+    	if (properties == null) {
+    		return null;
+    	}
+        return properties.get(name);
+    }
+
+    /**
+     * Get a given property by its name.
+     *
+     * @param name the name of the property to retrieve
+     * @return the value of the property or <code>null</code> if none has been set
+     */
+    public <T> T getProperty(String name, Class<T> type) {
+    	if (properties == null) {
+    		return null;
+    	}
+        // TODO: use converters
+        return (T) properties.get(name);
+    }
+
+    /**
+     * Get a typed property
+     *
+     * @param type the type
+     * @return the value
+     */
+    public <T> T getProperty(Class<T> type) {
+        if (properties == null) {
+            return null;
+        }
+        return (T) properties.get(type.getName());
+    }
+
+    /**
+     * Set a property on this exchange.
+     * Giving <code>null</code> will actually remove the property for the list.
+     *
+     * @param name  the name of the property
+     * @param value the value for this property or <code>null</code>
+     */
+    public void setProperty(String name, Object value) {
+    	if (properties == null) {
+    		properties = new HashMap<String, Object>();
+    	}
+        properties.put(name, value);
+    }
+
+    public <T> void setProperty(Class<T> type, T value) {
+        if (properties == null) {
+            properties = new HashMap<String, Object>();
+        }
+        properties.put(type.getName(), value);
+    }
+
+    public Map<String, Object> getProperties() {
+        if (properties == null) {
+            properties = new HashMap<String, Object>();
+        }
+        return properties;
+    }
+
+    public void setProperties(Map<String, Object> properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Obtains the input message
+     *
+     * @return the input message or <code>null</code> if
+     *         this pattern do not have any
+     */
+    public Message getIn() {
+        return getIn(true);
+    }
+    
+    public Message getIn(boolean lazyCreate) {
+        if (this.in == null) {
+            this.in = createMessage();
+        }
+        return this.in;
+    }
+
+    /**
+     * Obtains the output message
+     *
+     * @return the output message or <code>null</code> if
+     *         this pattern does not have any
+     */
+    public Message getOut() {
+        return getOut(true);
+    }
+
+    public Message getOut(boolean lazyCreate) {
+        if (this.out == null) {
+            if (this.pattern != Pattern.InOnly && this.pattern != Pattern.RobustInOnly) {
+                this.out = createMessage();
+            }
+        }
+        return this.out;
+    }
+
+    /**
+     * Obtains the fault message
+     *
+     * @return the fault message
+     */
+    public Message getFault() {
+        return getFault(true);
+    }
+
+    public Message getFault(boolean lazyCreate) {
+        if (this.fault == null) {
+            if (this.pattern != Pattern.InOnly) {
+                this.fault = createMessage();
+            }
+        }
+        return this.fault;
+    }
+
+    /**
+     * Obtains the message of the given type
+     *
+     * @return the message or <code>null</code> if
+     *         this pattern does not support this type of message
+     */
+    public Message getMessage(Type type) {
+        return getMessage(type, true);
+    }
+    
+    public Message getMessage(Type type, boolean lazyCreate) {
+        switch (type) {
+            case In: return getIn(lazyCreate);
+            case Out: return getOut(lazyCreate);
+            case Fault: return getFault(lazyCreate);
+            default: throw new IllegalArgumentException();
+        }
+    }
+    
+    protected Message createMessage() {
+    	return new MessageImpl();
+    }
+
+    /**
+     * Obtains the error of this exchange
+     *
+     * @return the exception that caused the exchange to fail
+     */
+    public Exception getError() {
+        return error;
+    }
+    
+    public void setError(Exception error) {
+    	this.error = error;
+    }
+
+	public void ensureReReadable() {
+		if (in != null) {
+			in.ensureReReadable();
+		}
+		if (out != null) {
+			out.ensureReReadable();
+		}
+		if (fault != null) {
+			fault.ensureReReadable();
+		}
+	}
+
+    /**
+     * Copy this exchange
+     */
+	public void copyFrom(Exchange exchange) {
+		this.error = exchange.getError();
+		if (exchange.getFault() != null) {
+			this.fault = exchange.getFault().copy();
+		}
+		if (exchange.getIn() != null) {
+			this.in = exchange.getIn().copy();
+		}
+		if (exchange.getOut() != null) {
+			this.out = exchange.getOut().copy();
+		}
+		this.pattern = exchange.getPattern();
+        this.properties = new HashMap<String, Object>(exchange.getProperties());
+		this.role = exchange.getRole();
+		this.target = exchange.getTarget();
+	}
+	
+    public Exchange copy() {
+    	ExchangeImpl copy = new ExchangeImpl();
+        copy.copyFrom(this);
+        return copy;
+    }
+
+	private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+		ensureReReadable();
+		out.defaultWriteObject();
+	}
+	
+	public String display(boolean displayContent) {
+		if (displayContent) {
+			ensureReReadable();
+		}
+		return "Exchange []";
+	}
+
+	public String toString() {
+		return display(true);
+	}
+
+}

Added: incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/MessageImpl.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/MessageImpl.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/MessageImpl.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.core;
+
+import org.apache.servicemix.api.Message;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Revision: $
+ * @since 4.0
+ */
+public class MessageImpl implements Message {
+
+    /**
+	 * Generated serial version UID 
+	 */
+	private static final long serialVersionUID = -8621182821298293687L;
+
+	private Object content;
+    private String contentType;
+    private String contentEncoding;
+    private Map<String, Object> headers;
+    private Map<String, Object> attachments;
+
+    public MessageImpl() {
+    }
+
+    public Object getContent() {
+        return content;
+    }
+
+    public <T> T getContent(Class<T> type) {
+        // TODO: use converters
+        if (type.isInstance(content)) {
+            return (T) content;
+        }
+        return null;
+    }
+
+    public void setContent(Object content) {
+        this.content = content;
+    }
+
+    /**
+     * Get the mime content type describing the content of the message
+     *
+     * @return the mime content type
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    /**
+     * Set the mime content type describing the content of the message
+     *
+     * @param type the mime content type
+     */
+    public void setContentType(String type) {
+        this.contentType = type;
+    }
+
+    /**
+     * Get the encoding of the message
+     *
+     * @return the encoding
+     */
+    public String getContentEncoding() {
+        return contentEncoding;
+    }
+
+    /**
+     * Set the encoding of the message
+     *
+     * @param encoding the encoding
+     */
+    public void setContentEncoding(String encoding) {
+        this.contentEncoding = encoding;
+    }
+
+    public Object getHeader(String name) {
+        if (headers == null) {
+            return null;
+        }
+        return headers.get(name);
+    }
+
+    public <T> T getHeader(String name, Class<T> type) {
+        if (headers == null) {
+            return null;
+        }
+        return (T) headers.get(name);
+    }
+
+    public <T> T getHeader(Class<T> type) {
+        if (headers == null) {
+            return null;
+        }
+        return (T) headers.get(type.getName());
+    }
+
+    public void setHeader(String name, Object value) {
+        if (headers == null) {
+            headers = new HashMap<String, Object>();
+        }
+        headers.put(name, value);
+    }
+
+    public <T> void setHeader(Class<T> type, T value) {
+        if (headers == null) {
+            headers = new HashMap<String, Object>();
+        }
+        headers.put(type.getName(), value);
+    }
+
+    public Map<String, Object> getHeaders() {
+        if (headers == null) {
+            headers = new HashMap<String, Object>();
+        }
+        return headers;
+    }
+
+    public Object getAttachment(String id) {
+        if (attachments != null) {
+            return null;
+        }
+        return attachments.get(id);
+    }
+
+    public void addAttachment(String id, Object value) {
+        if (attachments != null) {
+            attachments = new HashMap<String, Object>();
+        }
+        attachments.put(id, value);
+    }
+
+    public void removeAttachment(String id) {
+        if (attachments != null) {
+            attachments.remove(id);
+        }
+    }
+
+    public Map<String, Object> getAttachments() {
+        if (attachments != null) {
+            attachments = new HashMap<String, Object>();
+        }
+        return attachments;
+    }
+
+    public void ensureReReadable() {
+        // TODO: implement        
+    }
+
+    public void copyFrom(Message msg) {
+        content = msg.getContent();
+        if (!msg.getHeaders().isEmpty()) {
+            headers = new HashMap<String, Object>();
+            for (Map.Entry<String, Object> e : msg.getHeaders().entrySet()) {
+                headers.put(e.getKey(), e.getValue());
+            }
+        } else {
+            headers = null;
+        }
+        if (!msg.getAttachments().isEmpty()) {
+            attachments = new HashMap<String, Object>();
+            for (Map.Entry<String, Object> e : msg.getAttachments().entrySet()) {
+                attachments.put(e.getKey(), e.getValue());
+            }
+        } else {
+            attachments = null;
+        }
+    }
+
+    public Message copy() {
+        MessageImpl copy = new MessageImpl();
+        copy.copyFrom(this);
+        return copy;
+    }
+
+	private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+		ensureReReadable();
+		out.defaultWriteObject();
+	}
+
+	public String display(boolean displayContent) {
+		if (displayContent) {
+			ensureReReadable();
+		}
+		return "Message []";
+	}
+
+	public String toString() {
+		return display(true);
+	}
+}

Added: incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/ExchangeImplTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/ExchangeImplTest.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/ExchangeImplTest.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/ExchangeImplTest.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.core;
+
+import static org.junit.Assert.*;
+
+import org.apache.servicemix.api.Exchange;
+import org.apache.servicemix.api.Pattern;
+import org.junit.Test;
+
+
+public class ExchangeImplTest {
+
+	@Test
+	public void testInOnly() {
+		Exchange e = new ExchangeImpl(Pattern.InOnly);
+		assertNotNull(e.getIn());
+		assertNull(e.getOut());
+		assertNull(e.getFault());
+	}
+
+	@Test
+	public void testRobustInOnly() {
+		Exchange e = new ExchangeImpl(Pattern.RobustInOnly);
+		assertNotNull(e.getIn());
+		assertNull(e.getOut());
+		assertNotNull(e.getFault());
+	}
+
+	@Test
+	public void testInOut() {
+		Exchange e = new ExchangeImpl(Pattern.InOut);
+		assertNotNull(e.getIn());
+		assertNotNull(e.getOut());
+		assertNotNull(e.getFault());
+	}
+
+	@Test
+	public void testInOptionalOut() {
+		Exchange e = new ExchangeImpl(Pattern.InOptionalOut);
+		assertNotNull(e.getIn());
+		assertNotNull(e.getOut());
+		assertNotNull(e.getFault());
+	}
+
+}

Added: incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/MessageImplTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/MessageImplTest.java?rev=568917&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/MessageImplTest.java (added)
+++ incubator/servicemix/branches/servicemix-4.0/core/src/test/java/org/apache/servicemix/core/MessageImplTest.java Thu Aug 23 03:15:05 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.core;
+
+import static org.junit.Assert.*;
+
+import org.apache.servicemix.api.Message;
+import org.junit.Test;
+
+public class MessageImplTest {
+
+    @Test
+    public void testHeaders() {
+        Message msg = new MessageImpl();
+        assertNotNull(msg.getHeaders());
+    }
+
+}

Modified: incubator/servicemix/branches/servicemix-4.0/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/pom.xml?rev=568917&r1=568916&r2=568917&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/pom.xml Thu Aug 23 03:15:05 2007
@@ -25,9 +25,11 @@
   <artifactId>servicemix</artifactId>
   <packaging>pom</packaging>
   <version>4.0-SNAPSHOT</version>
+  <name>servicemix</name>
 
   <modules>
 	<module>api</module>
+	<module>core</module>
   </modules>
 
   <build>
@@ -50,4 +52,17 @@
     </pluginManagement>
   </build>
 
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>2.0</version>
+      </plugin>
+    </plugins>
+  </reporting>
 </project>