Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jacorb.notification.servant;
  
  /*
   *        JacORB - a free Java ORB
   *
   *   Copyright (C) 1997-2012 Gerald Brose / The JacORB Team.
   *
   *   This library is free software; you can redistribute it and/or
   *   modify it under the terms of the GNU Library General Public
  *   License as published by the Free Software Foundation; either
  *   version 2 of the License, or (at your option) any later version.
  *
  *   This library is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *   Library General Public License for more details.
  *
  *   You should have received a copy of the GNU Library General Public
  *   License along with this library; if not, write to the Free
  *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 import java.util.Map;

Author(s):
Alphonse Bendt
Jmx.mbean:
extends = "AbstractProxyConsumerMBean"
Jboss.xmbean:
 
 
 public class TypedProxyPullConsumerImpl extends AbstractProxyConsumer implements
 {
     private String[] tryPullOperations_;
 
     private TypedPullSupplier pullSupplier_;
 
     private org.omg.CORBA.Object typedPullSupplier_;
 
     private InterfaceDef interfaceDef_;
 
     private final String supportedInterface_;
 
     private final Map operationDescriptions_ = new HashMap();
 
     private final Map fullQualifiedOperationNames_ = new HashMap();
 
     private final PullMessagesUtility pollUtil_;
 
     private long pollInterval_;
 
 
     public TypedProxyPullConsumerImpl(ITypedAdmin adminSupplierAdmin supplierAdminORB orb,
             POA poaConfiguration configTaskProcessor taskProcessor,
             MessageFactory messageFactoryOfferManager offerManager,
             SubscriptionManager subscriptionManager)
     {
         super(adminorbpoaconfigtaskProcessormessageFactorysupplierAdminofferManager,
                 subscriptionManager);
 
          = admin.getSupportedInterface();
 
          = new PullMessagesUtility(taskProcessorthis);
        try
        {
                                                     .);
        }
        catch (ConfigurationException ex)
        {
           config.getLogger ("TypedProxyPullConsumerImpl").error
              ("Error configuring " + .ex);
           throw new INTERNAL ("Error configuring TypedProxyPullConsumerImpl" + ex);
        }
         = new PullMessagesOperation(this);
    }
    // ////////////////////////////
    public void connect_typed_pull_supplier(TypedPullSupplier typedPullSupplier)
            throws AlreadyConnectedTypeError
    {
        .info("connect typed_pull_supplier");
        checkIsNotConnected();
        connectClient(typedPullSupplier);
         = typedPullSupplier;
         = InterfaceDefHelper.narrow(._get_interface_def());
        if ( == null)
        {
            throw new TypeError("Could not access Interface Definition for TypedPullSupplier [" +  + "]");
        }
        {
            throw new TypeError();
        }
    }
    private String[] getTryPullOperations()
    {
        if ( == null)
        {
            FullInterfaceDescription _fullIfDescription = .describe_interface();
            for (int x = 0; x < _fullIfDescription.operations.length; ++x)
            {
                if (_fullIfDescription.operations[x]..startsWith("try_"))
                {
                    .put(_fullIfDescription.operations[x].,
                            _fullIfDescription.operations[x]);
                }
            }
                    new String[.size()]);
        }
        return ;
    }
    {
        final String[] _tryPullOperations = getTryPullOperations();
        final Map _successFulRequests = new HashMap();
        for (int x = 0; x < _tryPullOperations.length; ++x)
        {
            Request _request = prepareRequest(_tryPullOperations[x]);
            if (.isDebugEnabled())
            {
                .debug("invoke " + _tryPullOperations[x]);
            }
            try
            {
                _request.invoke();
                Any _result = _request.result().value();
                boolean _success = _result.extract_boolean();
                if (_success)
                {
                    String _operationNameWithoutTry = _tryPullOperations[x].substring(4);
                    _successFulRequests.put(_operationNameWithoutTry_request);
                }
            } catch (Exception e)
            {
                if (.isInfoEnabled())
                {
                    String _mesg = "Operation " + _tryPullOperations[x] + " failed: Ignore";
                    if (.isDebugEnabled())
                    {
                        .debug(_mesge);
                    }
                    else
                    {
                        .info(_mesg);
                    }
                }
            }
        }
        return new MessageSupplierDelegate.PullResult(Collections.unmodifiableMap(_successFulRequests), true);
    }
    public void queueMessages(PullResult data)
    {
        final Map _successfulRequests = (Mapdata.data_;
        for (Iterator i = _successfulRequests.keySet().iterator(); i.hasNext();)
        {
            String _operationNameWithoutTry = (Stringi.next();
            Request _request = (Request_successfulRequests.get(_operationNameWithoutTry);
            String _operationName = getFullQualifiedName(_operationNameWithoutTry);
            Message _mesg = getMessageFactory().newMessage(_operationName,
                    _request.arguments(), this);
            checkMessageProperties(_mesg);
            processMessage(_mesg);
        }
    }
    {
        return (OperationDescription.get(operation);
    }
    private String getFullQualifiedName(String operation)
    {
        String _fullQualifiedName = (String.get(operation);
        if (_fullQualifiedName == null)
        {
            _fullQualifiedName = .lookup(operation).absolute_name();
            .put(operation_fullQualifiedName);
        }
        return _fullQualifiedName;
    }
    private Request prepareRequest(String operation)
    {
        final Request _request = ._request(operation);
        final NVList _args = _request.arguments();
        final OperationDescription _operationDescription = getOperationDescription(operation);
        for (int x = 0; x < _operationDescription.parameters.length; ++x)
        {
            final Any _any = getORB().create_any();
            _any.type(_operationDescription.parameters[x].);
            _args.add_value(_operationDescription.parameters[x]._any.);
        }
        _request.set_return_type(_operationDescription.result);
        return _request;
    }
    public void disconnect_pull_consumer()
    {
        destroy();
    }
    public ProxyType MyType()
    {
        return .;
    }
    public void disconnectClient()
    {
        .stopTask();
        if ( != null)
        {
            .disconnect_pull_supplier();
             = null;
        }
    }
    public Servant newServant()
    {
        return new TypedProxyPullConsumerPOATie(this);
    }

    

Jmx.managed:
attribute access = "read-only"
    public String getSupportedInterface()
    {
        return ;
    }
    public void runPullMessage() throws Disconnected
    {
    }
New to GrepCode? Check out our FAQ X