Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jacorb.notification.servant;
  
  /*
   *        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.
  *
  */
 
 import java.util.List;
 import java.util.Set;
 
 import  org.picocontainer.PicoContainer;
 

Author(s):
Alphonse Bendt
Jmx.mbean:
Jboss.xmbean:
 
 
 public abstract class AbstractProxy implements FilterAdminOperationsQoSAdminOperations,
         FilterStageIServantLifecyleConfigurable, JMXManageable, AbstractProxyMBean
 {
     private final MappingFilter nullMappingFilterRef_;
 
     private final boolean isIDPublic_;
 
     protected final Logger logger_;
 
     private final AtomicBoolean connected_ = new AtomicBoolean(false);
 
     protected final QoSPropertySet qosSettings_;
 
     private final Integer id_;
 
     protected final OfferManager offerManager_;
 
     protected final SubscriptionManager subscriptionManager_;
 
     private MappingFilter lifetimeFilter_;
 
     private MappingFilter priorityFilter_;

    
delegate for FilterAdminOperations
    private final FilterManager filterManager_;
    private final AtomicBoolean destroyed_ = new AtomicBoolean(false);
    private final AtomicBoolean disposeInProgress_ = new AtomicBoolean(false);
    private final AtomicInteger errorCounter_ = new AtomicInteger(0);
    private final POA poa_;
    private final ORB orb_;
    private final TaskProcessor taskProcessor_;
    private boolean isInterFilterGroupOperatorOR_;
    private final boolean disposedProxyDisconnectsClient_;
    private final AtomicBoolean active_ = new AtomicBoolean(true);
    private final DisposableManager disposables_ = new DisposableManager();
    private final PicoContainer container_;
    private org.omg.CORBA.Object client_;
    private final String parentMBean_;
    protected final Set eventTypes_ = new HashSet();
    
    protected Configuration config_;
    
    
    // //////////////////////////////////////
    protected AbstractProxy(IAdmin adminORB orbPOA poaConfiguration conf,
            TaskProcessor taskProcessorOfferManager offerManager,
            SubscriptionManager subscriptionManager)
    {
         = admin.getAdminMBean();
         = new Integer(admin.getProxyID());
         = admin.isIDPublic();
         = admin.getContainer();
         = orb;
         = poa;
         = taskProcessor;
        
         = offerManager;
         = subscriptionManager;
         = new FilterManager();
         = MappingFilterHelper.narrow(orb.string_to_object(orb.object_to_string(null)));
         = ((org.jacorb.config.Configurationconf).getLogger(getClass().getName());
                .,
                .).equals("on");
         = new QoSPropertySet(conf.);
         = new ServantLifecyleControl(thisconf);
        
        configure(conf);
    }
    public void configure(Configuration conf)
    {
         = conf;
    }
    // //////////////////////////////////////
    public void registerDisposable(Disposable d)
    {
        .addDisposable(d);
    }
    public boolean isIDPublic()
    {
        return ;
    }
    public final POA getPOA()
    {
        return ;
    }
    protected ORB getORB()
    {
        return ;
    }
    public final org.omg.CORBA.Object activate()
    {
        return .activate();
    }
    
    protected TaskProcessor getTaskProcessor()
    {
        return ;
    }
    // ////////////////////////////////////////////////////
    // delegate FilterAdmin Operations to FilterManager //
    // ////////////////////////////////////////////////////
    public final int add_filter(Filter filter)
    {
        return .add_filter(filter);
    }
    public final void remove_filter(int nthrows FilterNotFound
    {
        .remove_filter(n);
    }
    public final Filter get_filter(int nthrows FilterNotFound
    {
        return .get_filter(n);
    }
    public final int[] get_all_filters()
    {
        return .get_all_filters();
    }
    public final void remove_all_filters()
    {
    }
    // //////////////////////////////////////
    // TODO implement
    public void validate_event_qos(Property[] qosPropsNamedPropertyRangeSeqHolder propSeqHolder)
    {
        throw new NO_IMPLEMENT();
    }
    public final void validate_qos(Property[] propsNamedPropertyRangeSeqHolder propertyRange)
            throws UnsupportedQoS
    {
        .validate_qos(propspropertyRange);
    }
    public final void set_qos(Property[] qosPropsthrows UnsupportedQoS
    {
        .set_qos(qosProps);
    }
    public final Property[] get_qos()
    {
        return .get_qos();
    }
    public final void priority_filter(MappingFilter filter)
    {
         = filter;
    }
    public final MappingFilter priority_filter()
    {
        if ( == null)
        {
            return ;
        }
        return ;
    }
    public final MappingFilter lifetime_filter()
    {
        if ( == null)
        {
            return ;
        }
        return ;
    }
    public final void lifetime_filter(MappingFilter filter)
    {
         = filter;
    }
    public final Integer getID()
    {
        return ;
    }
    public final List getFilters()
    {
        return .getFilters();
    }
    public final void deactivate()
    {
        .deactivate();
    }
    private void tryDisconnectClient()
    {
        try
        {
            if ( && .get())
            {
                .info("disconnect_client");
                disconnectClient();
                
                ._release();
            }
        } catch (Exception e)
        {
            .info("disconnect_client raised an unexpected error: will be ignored"e);
        } finally
        {
            .set(false);
             = null;
        }
    }
    public final boolean isDestroyed()
    {
        return .get();
    }
    protected void checkDestroyStatus() throws OBJECT_NOT_EXIST
    {
        if (!.compareAndSet(falsetrue))
        {
            .error("Already destroyed");
            throw new OBJECT_NOT_EXIST();
        }
    }

    

Jmx.managed:
operation description = "Destroy this Proxy" impact = "ACTION"
    public final void destroy()
    {
        checkDestroyStatus();
        .dispose();
        final List list = .getComponentInstancesOfType(IContainer.class);
        for (Iterator i = list.iterator(); i.hasNext();)
        {
            IContainer element = (IContaineri.next();
            element.destroy();
        }
    }
    public void dispose()
    {
        .info("Destroy Proxy " + );
        .set(true);
        // ////////////////////////////
        tryDisconnectClient();
        clientDisconnected();
        
        // ////////////////////////////
        removeListener();
        // ////////////////////////////
        remove_all_filters();
        // ////////////////////////////
        .dispose();
        deactivate();
    }
    protected abstract void clientDisconnected();
    
    public abstract ProxyType MyType();
    void setInterFilterGroupOperatorOR(boolean b)
    {
         = b;
    }
    public final boolean hasInterFilterGroupOperatorOR()
    {
        return ;
    }

    

Jmx.managed:
attribute description = "Connection Status." access = "read-only"
    public final boolean getConnected()
    {
        return !.get() && .get();
    }
    public final boolean hasLifetimeFilter()
    {
        return  != null;
    }
    public final boolean hasPriorityFilter()
    {
        return  != null;
    }
    public final MappingFilter getLifetimeFilter()
    {
        return ;
    }
    public final MappingFilter getPriorityFilter()
    {
        return ;
    }

    

Jmx.managed:
operation impact = "ACTION" description = "reset the error counter to its initial value"
    public void resetErrorCounter()
    {
        .set(0);
    }
 
    

Jmx.managed:
attribute description = "error counter" access = "read-only"
    public final int getErrorCounter()
    {
        return .get();
    }
    public final int incErrorCounter()
    {
        return .getAndIncrement();
    }
    public boolean isSuspended()
    {
        return !.get();
    }
    public final void suspend_connection() throws NotConnectedConnectionAlreadyInactive
    {
        checkIsConnected();
        if (!.compareAndSet(truefalse))
        {
            throw new ConnectionAlreadyInactive();
        }
        connectionSuspended();
    }

    
this is an extension point.
    protected void connectionSuspended()
    {
        // No Op
    }
    public final void resume_connection() throws NotConnectedConnectionAlreadyActive
    {
        checkIsConnected();
        if (!.compareAndSet(falsetrue))
        {
            throw new ConnectionAlreadyActive();
        }
        connectionResumed();
    }

    
this is an extension point. invoked when resume_connection was called successfully.
    protected void connectionResumed()
    {
        // NO OP
    }
    protected void checkIsConnected() throws NotConnected
    {
        if (!.get())
        {
            throw new NotConnected();
        }
    }
    protected void checkIsNotConnected() throws AlreadyConnected
    {
        if (.get())
        {
            throw new AlreadyConnected();
        }
    }
    protected void checkStillConnected() throws Disconnected
    {
        if (!.get())
        {
            .error("access on a not connected proxy");
            destroy();
            throw new Disconnected();
        }
    }
    protected void connectClient(org.omg.CORBA.Object client)
    {
        .set(true);
        
         = client;
    }

    
invoke the proxy specific disconnect method.
    protected abstract void disconnectClient();
    
    protected void handleDisconnected(Disconnected e)
    {
        .error("Illegal state: Client think it's disconnected. "
                + "Proxy thinks Client is still connected. The Proxy will be destroyed."e);
        destroy();
    }
    protected abstract void removeListener();
    public final String getJMXObjectName()
    {
        return  + ", proxy=" + getMBeanName();
    }
    
    public final String getMBeanName()
    {
        return getMBeanType() + "-" + getID();
    }
    protected String getMBeanType()
    {
        String clazzName = getClass().getName();
        
        String rawClazz = clazzName.substring(clazzName.lastIndexOf('.') + 1);
        
        return rawClazz.substring(0, rawClazz.length() - "Impl".length());
    }
    
    public String[] getJMXNotificationTypes()
    {
        return (String[]) .toArray(new String[.size()]);
    }
    
    public void setJMXCallback(JMXManageable.JMXCallback callback)
    {
         = callback;
    }
    
    protected void sendNotification(String typeString message)
    {
        if ( != null)
        {
            .sendJMXNotification(typemessage);
        }
    }
    
    protected void sendNotification(String typeString messageObject payload)
    {
        if ( != null)
        {
            .sendJMXNotification(typemessagepayload);
        }
    }
    
    

Jmx.managed:
attribute description = "current Status for this Proxy (NOT CONNECTED|ACTIVE|SUSPENDED|DESTROYED)" access = "read-only"
    public String getStatus()
    {
        final String _status;
        
        if (.get())
        {
            _status =  "DESTROYED";
        } 
        else if (!.get())
        {
            _status = "NOT CONNECTED";
        } else
        {
            _status = .get() ? "ACTIVE" : "SUSPENDED";
        }
        
        return _status;
    }
    
    

Jmx.managed:
attribute description = "IOR of the connected client" access = "read-only"
    public String getClientIOR()
    {
        return ( != null) ? .object_to_string() : "";
    }
    
    

Jmx.managed:
attribute description = "InterFilterGroupOperator used for this proxy" access = "read-only" currencyTimeLimit = "2147483647"
    {
        return  ? "OR_OP" : "AND_OP";
    }
New to GrepCode? Check out our FAQ X