servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r429278 - in /incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client: AbstractWSAClient.java CreatePullPoint.java JAXBMarshaler.java JAXBMarshaller.java NotificationBroker.java
Date Mon, 07 Aug 2006 08:41:47 GMT
Author: gnodet
Date: Mon Aug  7 01:41:46 2006
New Revision: 429278

URL: http://svn.apache.org/viewvc?rev=429278&view=rev
Log:
SM-508: Use Marshaler instead of Marshaller

Added:
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java
Removed:
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaller.java
Modified:
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java

Modified: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java?rev=429278&r1=429277&r2=429278&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
(original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
Mon Aug  7 01:41:46 2006
@@ -58,13 +58,13 @@
     
     public static ServiceMixClient createJaxbClient(JBIContainer container) throws JBIException,
JAXBException {
         DefaultServiceMixClient client = new DefaultServiceMixClient(container);
-        client.setMarshaler(new JAXBMarshaller(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
+        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
         return client;
     }
     
     public static ServiceMixClient createJaxbClient(ComponentContext context) throws JAXBException
{
         ServiceMixClientFacade client = new ServiceMixClientFacade(context); 
-        client.setMarshaler(new JAXBMarshaller(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
+        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
         return client;
     }
 	

Modified: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java?rev=429278&r1=429277&r2=429278&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
Mon Aug  7 01:41:46 2006
@@ -39,7 +39,7 @@
 	
 	public CreatePullPoint(ComponentContext context) throws JAXBException {
 		ServiceMixClientFacade client = new ServiceMixClientFacade(context); 
-		client.setMarshaler(new JAXBMarshaller(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
+		client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
 		setClient(client);
 		setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
 	}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java?rev=429278&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java
(added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java
Mon Aug  7 01:41:46 2006
@@ -0,0 +1,75 @@
+/*
+ * 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.wsn.client;
+
+import java.io.StringWriter;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.bind.JAXBContext;
+import javax.xml.transform.Source;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.messaging.DefaultMarshaler;
+
+public class JAXBMarshaler extends DefaultMarshaler {
+
+	private JAXBContext context;
+	
+	public JAXBMarshaler(JAXBContext context) {
+		this.context = context;
+	}
+
+	public JAXBContext getContext() {
+		return context;
+	}
+
+	public void setContext(JAXBContext context) {
+		this.context = context;
+	}
+	
+    protected Object defaultUnmarshal(MessageExchange exchange, NormalizedMessage message)
{
+        try {
+        	Source content = message.getContent();
+        	return context.createUnmarshaller().unmarshal(content);
+        } catch (Exception e) {
+        	throw new RuntimeException(e);
+        }
+    }
+
+    protected Source asContent(NormalizedMessage message, Object body) {
+    	try {
+	    	StringWriter writer = new StringWriter();
+	    	context.createMarshaller().marshal(body, writer);
+	    	return new StringSource(writer.toString());
+        } catch (Exception e) {
+        	throw new RuntimeException(e);
+        }
+    }
+
+	@Override
+	public void marshal(MessageExchange exchange, NormalizedMessage message, Object body) throws
MessagingException {
+		if (body instanceof Source) {
+            message.setContent((Source) body);
+        }
+        else {
+            Source content = asContent(message, body);
+            message.setContent(content);
+    	}
+	}
+}

Modified: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java?rev=429278&r1=429277&r2=429278&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java
(original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java
Mon Aug  7 01:41:46 2006
@@ -53,7 +53,7 @@
 	
 	public NotificationBroker(ComponentContext context) throws JAXBException {
 		ServiceMixClientFacade client = new ServiceMixClientFacade(context); 
-		client.setMarshaler(new JAXBMarshaller(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
+		client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
 		setClient(client);
 		setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
 	}



Mime
View raw message