01: /*
02: * $Id: KeyedPoolMessageRequesterFactoryAdapter.java 10961 2008-02-22 19:01:02Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.transport;
12:
13: import org.mule.api.MuleException;
14: import org.mule.api.endpoint.InboundEndpoint;
15: import org.mule.api.transport.MessageRequester;
16: import org.mule.api.transport.MessageRequesterFactory;
17: import org.mule.config.i18n.CoreMessages;
18:
19: import org.apache.commons.pool.KeyedPoolableObjectFactory;
20:
21: /**
22: * <code>KeyedPoolMessageRequesterFactoryAdapter</code> adapts a
23: * <code>MessageRequesterFactory</code> with methods from commons-pool
24: * <code>KeyedPoolableObjectFactory</code>. It is only required for requester
25: * factories that do not inherit from <code>AbstractMessageRequesterFactory</code>.
26: *
27: * @see org.mule.transport.AbstractMessageRequesterFactory
28: */
29: public class KeyedPoolMessageRequesterFactoryAdapter implements
30: MessageRequesterFactory, KeyedPoolableObjectFactory {
31: private final MessageRequesterFactory factory;
32:
33: public KeyedPoolMessageRequesterFactoryAdapter(
34: MessageRequesterFactory factory) {
35: super ();
36:
37: if (factory == null) {
38: throw new IllegalArgumentException(CoreMessages
39: .objectIsNull("factory").toString());
40: }
41:
42: this .factory = factory;
43: }
44:
45: public void activateObject(Object key, Object obj) throws Exception {
46: factory.activate((InboundEndpoint) key, (MessageRequester) obj);
47: }
48:
49: public void destroyObject(Object key, Object obj) throws Exception {
50: factory.destroy((InboundEndpoint) key, (MessageRequester) obj);
51: }
52:
53: public Object makeObject(Object key) throws Exception {
54: return factory.create((InboundEndpoint) key);
55: }
56:
57: public void passivateObject(Object key, Object obj)
58: throws Exception {
59: factory
60: .passivate((InboundEndpoint) key,
61: (MessageRequester) obj);
62: }
63:
64: public boolean validateObject(Object key, Object obj) {
65: return factory.validate((InboundEndpoint) key,
66: (MessageRequester) obj);
67: }
68:
69: public boolean isCreateRequesterPerRequest() {
70: return factory.isCreateRequesterPerRequest();
71: }
72:
73: public MessageRequester create(InboundEndpoint endpoint)
74: throws MuleException {
75: return factory.create(endpoint);
76: }
77:
78: public void activate(InboundEndpoint endpoint,
79: MessageRequester requester) throws MuleException {
80: factory.activate(endpoint, requester);
81: }
82:
83: public void destroy(InboundEndpoint endpoint,
84: MessageRequester requester) {
85: factory.destroy(endpoint, requester);
86: }
87:
88: public void passivate(InboundEndpoint endpoint,
89: MessageRequester requester) {
90: factory.passivate(endpoint, requester);
91: }
92:
93: public boolean validate(InboundEndpoint endpoint,
94: MessageRequester requester) {
95: return factory.validate(endpoint, requester);
96: }
97:
98: }
|