001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.nio.intraband.messaging;
016    
017    import com.liferay.portal.kernel.messaging.Destination;
018    import com.liferay.portal.kernel.messaging.MessageBus;
019    import com.liferay.portal.kernel.messaging.MessageBusUtil;
020    import com.liferay.portal.kernel.process.ProcessCallable;
021    import com.liferay.portal.kernel.process.ProcessException;
022    
023    /**
024     * @author Shuyang Zhou
025     */
026    public class DestinationConfigurationProcessCallable
027            implements ProcessCallable<Boolean> {
028    
029            public DestinationConfigurationProcessCallable(String destinationName) {
030                    _destinationName = destinationName;
031            }
032    
033            @Override
034            public Boolean call() throws ProcessException {
035                    MessageBus messageBus = MessageBusUtil.getMessageBus();
036    
037                    Destination destination = messageBus.getDestination(_destinationName);
038    
039                    if (destination == null) {
040                            throw new ProcessException("No such destination " + destination);
041                    }
042    
043                    if (destination instanceof IntrabandBridgeDestination) {
044                            return Boolean.FALSE;
045                    }
046    
047                    IntrabandBridgeDestination intrabandBridgeDestination =
048                            new IntrabandBridgeDestination(destination);
049    
050                    messageBus.addDestination(intrabandBridgeDestination);
051    
052                    return Boolean.TRUE;
053            }
054    
055            private static final long serialVersionUID = 1L;
056    
057            private String _destinationName;
058    
059    }