KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > gs > transformers > UMOMessageToGigaSpacesEntry


1 /*
2  * $Id: UMOMessageToGigaSpacesEntry.java 3807 2006-11-06 13:13:36Z holger $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.gs.transformers;
12
13 import net.jini.core.entry.Entry;
14
15 import org.mule.providers.gs.GigaSpacesEntryConverter;
16 import org.mule.transformers.AbstractEventAwareTransformer;
17 import org.mule.umo.UMOEventContext;
18 import org.mule.umo.UMOMessage;
19 import org.mule.umo.transformer.TransformerException;
20
21 public class UMOMessageToGigaSpacesEntry extends AbstractEventAwareTransformer
22 {
23     /**
24      * Serial version
25      */

26     private static final long serialVersionUID = -3378344993441495689L;
27
28     private final GigaSpacesEntryConverter converter = new GigaSpacesEntryConverter();
29
30     public UMOMessageToGigaSpacesEntry()
31     {
32         setReturnClass(Entry.class);
33     }
34
35     public Object JavaDoc transform(Object JavaDoc src, String JavaDoc encoding, UMOEventContext context) throws TransformerException
36     {
37         Object JavaDoc result = null;
38         UMOMessage msg = context.getMessage();
39         if (Object JavaDoc[].class.isAssignableFrom(src.getClass()))
40         {
41             Object JavaDoc[] srcArr = (Object JavaDoc[])src;
42             Object JavaDoc[] resultArr = new Object JavaDoc[srcArr.length];
43
44             for (int i = 0; i < srcArr.length; ++i)
45             {
46                 resultArr[i] = converter.toEntry(srcArr[i], msg);
47             }
48             result = resultArr;
49         }
50         else
51         {
52             result = converter.toEntry(src, msg);
53         }
54         return result;
55     }
56
57     protected Object JavaDoc checkReturnClass(Object JavaDoc object) throws TransformerException
58     {
59         // if (returnClass != null) {
60
// if (!returnClass.isInstance(object)) {
61
// throw new TransformerException(new
62
// Message(Messages.TRANSFORM_X_UNEXPECTED_TYPE_X,
63
// object.getClass().getName(),
64
// returnClass.getName()), this);
65
// }
66
// }
67
// logger.debug("The transformed object is of expected type. Type is: " +
68
// object.getClass().getName());
69
return object;
70     }
71
72 }
73
Popular Tags