KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > gs > GSConnector


1 /*
2  * $Id: GSConnector.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;
12
13 import org.mule.providers.gs.space.GSSpaceFactory;
14 import org.mule.providers.space.SpaceConnector;
15 import org.mule.umo.UMOComponent;
16 import org.mule.umo.endpoint.UMOEndpoint;
17 import org.mule.umo.endpoint.UMOImmutableEndpoint;
18 import org.mule.umo.space.UMOSpace;
19 import org.mule.umo.space.UMOSpaceException;
20
21 /**
22  * Provides a Space connector to be used with the GigaSpaces JavaSpaces
23  * implementation.
24  */

25 public class GSConnector extends SpaceConnector
26 {
27
28     private long transactionTimeout = 32 * 1000;
29
30     public GSConnector()
31     {
32         registerSupportedProtocol("rmi");
33         registerSupportedProtocol("java");
34         registerSupportedProtocol("jini");
35         setSpaceFactory(new GSSpaceFactory());
36     }
37
38     public String JavaDoc getProtocol()
39     {
40         return "gs";
41     }
42
43     public long getTransactionTimeout()
44     {
45         return transactionTimeout;
46     }
47
48     public void setTransactionTimeout(long transactionTimeout)
49     {
50         this.transactionTimeout = transactionTimeout;
51     }
52
53     /**
54      * The method determines the key used to store the receiver against.
55      *
56      * @param component the component for which the endpoint is being registered
57      * @param endpoint the endpoint being registered for the component
58      * @return the key to store the newly created receiver against
59      */

60     protected Object JavaDoc getReceiverKey(UMOComponent component, UMOEndpoint endpoint)
61     {
62         return endpoint.getEndpointURI().toString()
63                + (endpoint.getFilter() != null ? ":" + endpoint.getFilter() : "");
64     }
65
66     // /////// Do not cahce spaces /////////
67
/**
68      * Will look up a space based on the URI. If the Space is created this method
69      * will honour the transaction information on the endpoint and set the space up
70      * accordingly
71      *
72      * @param endpoint
73      * @return
74      * @throws org.mule.umo.space.UMOSpaceException
75      */

76     public UMOSpace getSpace(UMOEndpoint endpoint) throws UMOSpaceException
77     {
78         return getSpaceFactory().create(endpoint);
79     }
80
81     public UMOSpace getSpace(String JavaDoc spaceUrl) throws UMOSpaceException
82     {
83         return getSpaceFactory().create(spaceUrl);
84     }
85
86     protected String JavaDoc getSpaceKey(UMOImmutableEndpoint endpoint)
87     {
88         String JavaDoc spaceKey = super.getSpaceKey(endpoint);
89         spaceKey += (endpoint.getFilter() != null ? '#' + endpoint.getFilter().toString() : "");
90         return spaceKey;
91     }
92
93 }
94
Popular Tags