Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *        JacORB - a free Java ORB
   *
   *   Copyright (C) 1999-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.
  *
  */
 
 package org.jacorb.notification.container;
 
 import java.util.List;
 
 import  org.picocontainer.ComponentAdapter;
 import  org.picocontainer.PicoContainer;
 import  org.picocontainer.PicoInitializationException;
 import  org.picocontainer.PicoIntrospectionException;
 import  org.picocontainer.defaults.DecoratingComponentAdapter;
 
 public class BiDirGiopPOAComponentAdapter extends DecoratingComponentAdapter
 {
     private static final long serialVersionUID = 1L;
 
     private static final String BIDIR_GIOP_OPTION = "org.omg.PortableInterceptor.ORBInitializerClass.bidir_init";
 
     public BiDirGiopPOAComponentAdapter(ComponentAdapter delegate)
     {
         super(delegate);
     }
 
     private static boolean isBiDirGiopEnabled(Configuration config)
     {
         return (config.getAttribute(null) != null);
     }
 
     private static Policy newBiDirGiopPolicy(ORB orbthrows PolicyError
     {
         final Any _any = orb.create_any();
 
         BidirectionalPolicyValueHelper.insert(_any.);
 
         final Policy _policy = orb.create_policy(._any);
 
         return _policy;
     }
 
     public Object getComponentInstance(PicoContainer containerthrows PicoInitializationException,
             PicoIntrospectionException
     {
         final POA rootPOA = (POAsuper.getComponentInstance(container);
 
         final Configuration config = (Configurationcontainer.getComponentInstanceOfType(Configuration.class);
 
         final Logger _logger = LogUtil.getLogger(configgetClass().getName());
 
         try
         {
             final ORB orb = (ORBcontainer.getComponentInstanceOfType(ORB.class);
 
             final List _policyList = new ArrayList();
 
 
             addBiDirGiopPolicy(_policyListorbconfig);
 
             if (isBiDirGiopEnabled(config) && _logger.isInfoEnabled())
             {
                 _logger.info( 
                              + " is set:"
                              + " Will enable Bidirectional GIOP.");
             }
             
             org.omg.CORBA.Policy[] _policies = (org.omg.CORBA.Policy[]) _policyList
                    .toArray(new org.omg.CORBA.Policy[_policyList.size()]);
            POA poa = rootPOA.create_POA("NotifyServicePOA"rootPOA.the_POAManager(), _policies);
            for (int x = 0; x < _policies.length; ++x)
            {
                _policies[x].destroy();
            }
            return poa;
        } catch (UserException e)
        {
            throw new PicoInitializationException("Error enabling BiDirectional GIOP for POA"e);
        }
    }

    
    
add an optional Policy to enable Bidirectional GIOP to the supplied list. the decision if BiDir GIOP should be enabled is based on the Configuration settings.

Parameters:
policies will be modified by this method if BiDir GIOP is enabled
orb
config
Throws:
PolicyError
    public static void addBiDirGiopPolicy(List policiesORB orbConfiguration configthrows PolicyError
    {
        if (isBiDirGiopEnabled(config))
        {
            Policy policy = newBiDirGiopPolicy(orb);
            policies.add(policy);
        }
    }
New to GrepCode? Check out our FAQ X