001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.bpmscript.jbi;
018:
019: import java.lang.reflect.Proxy;
020:
021: import javax.xml.namespace.QName;
022:
023: import org.apache.servicemix.client.DefaultServiceMixClient;
024: import org.apache.servicemix.jbi.messaging.DefaultMarshaler;
025: import org.apache.servicemix.jbi.messaging.PojoMarshaler;
026: import org.bpmscript.ExceptionMapper;
027: import org.bpmscript.RuntimeExceptionMapper;
028: import org.springframework.beans.factory.FactoryBean;
029:
030: public class PojoServiceProxyFactoryBean implements FactoryBean {
031:
032: private DefaultServiceMixClient client;
033: private PojoMarshaler marshaler = new DefaultMarshaler();
034: private QName service;
035: private long timeout = 0;
036: private ExceptionMapper exceptionMapper = new RuntimeExceptionMapper();
037: private Class interfaceClass;
038:
039: public Object getObject() throws Exception {
040: return Proxy.newProxyInstance(this .getClass().getClassLoader(),
041: new Class[] { IRemoteService.class, interfaceClass },
042: new PojoServiceProxy(client, marshaler, service,
043: timeout, exceptionMapper));
044: }
045:
046: public Class getObjectType() {
047: return interfaceClass;
048: }
049:
050: public boolean isSingleton() {
051: return true;
052: }
053:
054: public DefaultServiceMixClient getClient() {
055: return client;
056: }
057:
058: public void setClient(DefaultServiceMixClient client) {
059: this .client = client;
060: }
061:
062: public ExceptionMapper getExceptionMapper() {
063: return exceptionMapper;
064: }
065:
066: public void setExceptionMapper(ExceptionMapper exceptionMapper) {
067: this .exceptionMapper = exceptionMapper;
068: }
069:
070: public Class getInterfaceClass() {
071: return interfaceClass;
072: }
073:
074: public void setInterfaceClass(Class interfaceClass) {
075: this .interfaceClass = interfaceClass;
076: }
077:
078: public PojoMarshaler getMarshaler() {
079: return marshaler;
080: }
081:
082: public void setMarshaler(PojoMarshaler marshaler) {
083: this .marshaler = marshaler;
084: }
085:
086: public QName getService() {
087: return service;
088: }
089:
090: public void setService(QName service) {
091: this .service = service;
092: }
093:
094: public long getTimeout() {
095: return timeout;
096: }
097:
098: public void setTimeout(long timeout) {
099: this.timeout = timeout;
100: }
101:
102: }
|