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.jmx;
 
 
 
 import  org.nanocontainer.remoting.jmx.DynamicMBeanProvider;
 import  org.nanocontainer.remoting.jmx.JMXExposingComponentAdapterFactory;
 import  org.picocontainer.MutablePicoContainer;
 import  org.picocontainer.defaults.CachingComponentAdapterFactory;
 import  org.picocontainer.defaults.ComponentAdapterFactory;
 import  org.picocontainer.defaults.ConstructorInjectionComponentAdapterFactory;
 import  org.picocontainer.defaults.DefaultPicoContainer;

Author(s):
Alphonse Bendt
Jmx.mbean:
name="COSNotificationServiceMBean" description="Control the JacORB Notification Service"
 
 {
     private AbstractChannelFactory factory_;
 
     private final MutablePicoContainer container_;
 
     private final static String STARTED = "EventChannelFactory was started";
 
     private final static String RUNNING = "EventChannelFactory is running";
 
     private final static String NOT_RUNNING = "EventChannelFactory is not running";
 
     private final static String STOPPED = "EventChannelFactory was stopped";
 
     private final static String IOR_DEFAULT = "IOR:0";
 
     private final static String CORBALOC_DEFAULT = "<undefined>";
 
     private final Logger logger_ = LogUtil.getLogger(getClass().getName());
 
     private final Properties properties_;
 
     private final ORB optionalORB_;
 
     public COSNotificationService(ORB orbMBeanServer mbeanServer,
             DynamicMBeanProvider mbeanProviderString[] args)
     {
         super();
 
          = orb;
          = ConsoleMain.parseProperties(args);
 
         DynamicMBeanProvider _decoratedProvider = new UnregisterObjectNameProviderDecorator(
                 mbeanServermbeanProvider);
 
         ComponentAdapterFactory _defaultCAF = new JMXExposingComponentAdapterFactory(
                 new ConstructorInjectionComponentAdapterFactory(), mbeanServer,
                 new DynamicMBeanProvider[] { _decoratedProvider });
 
         ComponentAdapterFactory _cachingCAF = new CachingComponentAdapterFactory(
                 _defaultCAF);
 
          = new DefaultPicoContainer(_cachingCAF);
         .registerComponentInstance(ComponentAdapterFactory.class_defaultCAF);
     }

    

Jmx.managed:
operation description="create a new channel"
    public String createChannel()
    {
        try
        {
            if ( != null)
            {
                EventChannelFactoryImpl factory = (EventChannelFactoryImpl;
                IntHolder id = new IntHolder();
                factory.create_channel(new Property[0], new Property[0], id);
                return "Created Channel id=" + id.value;
            }
            return ;
        } catch (Exception e)
        {
            .error("Error creating Channel"e);
            throw new RuntimeException("Create channel failed: " + e.getMessage());
        }
    }
    public String start()
    {
        if ( != null)
        {
            return ;
        }
        try
        {
             = AbstractChannelFactory.newFactory();
            return ;
        } catch (Exception e)
        {
            .error("Error starting Service"e);
            throw new RuntimeException("Start failed: " + e.getMessage());
        }
    }
    public String stop()
    {
        if ( != null)
        {
            .dispose();
             = null;
            return ;
        }
        return ;
    }

    

Jmx.managed:
attribute description="IOR to access the EventChannelFactory" access = "read-only"
    public String getIOR()
    {
        return ( == null) ?  : .getIOR();
    }

    

Jmx.managed:
attribute description="Corbaloc to access the EventChannelFactory access = "read-only"
    public String getCorbaloc()
    {
        return ( == null) ?  : .getCorbaLoc();
    }

    

Jmx.managed:
attribute description = "Filename the IOR should be written to" access = "read-write"
    public String getIORFile()
    {
        return .getProperty(.);
    }

    

Jmx.managed:
attribute
    public void setIORFile(String filenamethrows IOException
    {
        .setProperty(.filename);
        if ( != null)
        {
            .writeIOR(filename);
        }
    }

    

Jmx.managed:
attribute description = "NameService Entry (Optional)" access = "read-write"
    public String getCOSNamingEntry()
    {
                "<undefined>"));
        final String nameKind = .getProperty(.);
        if (nameKind != null)
        {
            name.append('.');
            name.append(nameKind);
        }
        return name.toString();
    }

    

Jmx.managed:
attribute
    public void setCOSNamingEntry(String registerName)
    {
        ConsoleMain.addCOSNamingName(registerName);
        if ( != null)
        {
            try
            {
                .unregisterName();
                .registerName();
            } catch (Exception e)
            {
                .error("Error changing COSNaming entry"e);
                throw new RuntimeException("Changing the COSNaming entry failed: " + e.getMessage());
            }
        }
    }
    
    {
        return .activate();
    }
New to GrepCode? Check out our FAQ X