components/visual-panels/firewall/src/java/vpanels/app/firewall/com/oracle/solaris/vp/panels/firewall/client/swing/FirewallPanelDescriptor.java
branchs11-update
changeset 2805 4888f6212f94
parent 827 0944d8c0158b
equal deleted inserted replaced
2804:7546c836fd87 2805:4888f6212f94
    18  *
    18  *
    19  * CDDL HEADER END
    19  * CDDL HEADER END
    20  */
    20  */
    21 
    21 
    22 /*
    22 /*
    23  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
    23  * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
    24  */
    24  */
    25 
    25 
    26 package com.oracle.solaris.vp.panels.firewall.client.swing;
    26 package com.oracle.solaris.vp.panels.firewall.client.swing;
    27 
    27 
    28 import java.beans.PropertyChangeEvent;
    28 import java.beans.PropertyChangeEvent;
    29 import java.io.IOException;
    29 import java.io.IOException;
    30 import java.net.UnknownHostException;
    30 import java.net.UnknownHostException;
    31 import java.util.*;
    31 import java.util.*;
    32 import javax.management.*;
       
    33 import javax.management.remote.JMXConnector;
       
    34 import javax.swing.*;
    32 import javax.swing.*;
    35 import javax.swing.filechooser.FileSystemView;
    33 import javax.swing.filechooser.FileSystemView;
    36 import com.oracle.solaris.adr.Stability;
    34 import com.oracle.solaris.rad.client.RadObjectException;
    37 import com.oracle.solaris.rad.ObjectException;
    35 import com.oracle.solaris.rad.connect.Connection;
    38 import com.oracle.solaris.rad.jmx.RadJMX;
       
    39 import com.oracle.solaris.scf.common.ScfException;
    36 import com.oracle.solaris.scf.common.ScfException;
    40 import com.oracle.solaris.vp.panel.common.*;
    37 import com.oracle.solaris.vp.panel.common.*;
    41 import com.oracle.solaris.vp.panel.common.api.network.*;
    38 import com.oracle.solaris.vp.panel.common.api.network.*;
    42 import com.oracle.solaris.vp.panel.common.api.file.RemoteFileSystemView;
    39 import com.oracle.solaris.vp.panel.common.api.file.RemoteFileSystemView;
    43 import com.oracle.solaris.vp.panel.common.api.smf_old.*;
    40 import com.oracle.solaris.vp.panel.common.api.smf_old.*;
    81     public AccessPolicy ovrPolicy = new SimpleAccessPolicy(
    78     public AccessPolicy ovrPolicy = new SimpleAccessPolicy(
    82 	AccessPolicy.Type.NONE);
    79 	AccessPolicy.Type.NONE);
    83 
    80 
    84     private DefaultControl control;
    81     private DefaultControl control;
    85     private RemoteFileSystemView fsView;
    82     private RemoteFileSystemView fsView;
    86     private MXBeanTracker<NetworkMXBean> networkBeanTracker;
    83     private BeanTracker<Network> networkBeanTracker;
    87     private SimpleHasId tmpHasId = new SimpleHasId();
    84     private SimpleHasId tmpHasId = new SimpleHasId();
    88 
    85 
    89     private SimpleSmfPropertyGroupInfo defaultPgInfo;
    86     private SimpleSmfPropertyGroupInfo defaultPgInfo;
    90     private SimpleSmfPropertyGroupInfo overridePgInfo;
    87     private SimpleSmfPropertyGroupInfo overridePgInfo;
    91 
    88 
    97     //
    94     //
    98     // Constructors
    95     // Constructors
    99     //
    96     //
   100 
    97 
   101     public FirewallPanelDescriptor(String id,
    98     public FirewallPanelDescriptor(String id,
   102 	ClientContext context) throws InstanceNotFoundException, IOException,
    99 	ClientContext context) throws IOException,
   103 	ScfException, InvalidScfDataException, MissingScfDataException,
   100 	ScfException, InvalidScfDataException, MissingScfDataException,
   104 	JMException, TrackerException {
   101 	TrackerException {
   105 
   102 
   106 	super(id, context, SERVICE, INSTANCE);
   103 	super(id, context, SERVICE, INSTANCE);
   107 
   104 
   108 	fsView = new RemoteFileSystemView(context);
   105 	fsView = new RemoteFileSystemView(context);
   109 
   106 
   110 	networkBeanTracker = new MXBeanTracker<NetworkMXBean>(
   107 	networkBeanTracker = new BeanTracker<Network>(
   111 	    NetworkUtil.OBJECT_NAME, NetworkMXBean.class, Stability.PRIVATE,
   108 	    (new Network()).getName(), Network.class, context);
   112 	    context);
       
   113 
   109 
   114 	setComparator(SimpleHasId.COMPARATOR);
   110 	setComparator(SimpleHasId.COMPARATOR);
   115 
   111 
   116 	defaultPgInfo = new SimpleSmfPropertyGroupInfo(
   112 	defaultPgInfo = new SimpleSmfPropertyGroupInfo(
   117 	    getService(), FW_GLOBAL_DEF_PG);
   113 	    getService(), FW_GLOBAL_DEF_PG);
   311 
   307 
   312 	if (getEnabledProperty().isChanged())
   308 	if (getEnabledProperty().isChanged())
   313 	    getEnabledProperty().reset();
   309 	    getEnabledProperty().reset();
   314     }
   310     }
   315 
   311 
   316     public NetworkMXBean getNetworkMXBean() {
   312     public Network getNetworkBean() {
   317 	return networkBeanTracker.getBean();
   313 	return networkBeanTracker.getBean();
   318     }
   314     }
   319 
   315 
   320     //
   316     //
   321     // Private methods
   317     // Private methods
   328 		services.add(-index - 1, s);
   324 		services.add(-index - 1, s);
   329 	}
   325 	}
   330     }
   326     }
   331 
   327 
   332     private void populateServiceList() throws ScfException,
   328     private void populateServiceList() throws ScfException,
   333 	InvalidScfDataException, MissingScfDataException, JMException {
   329 	InvalidScfDataException, MissingScfDataException {
   334 
   330 
   335 	ConnectionInfo cinfo = getClientContext().getConnectionInfo();
   331 	ConnectionInfo cinfo = getClientContext().getConnectionInfo();
   336 	JMXConnector jmxc = cinfo.getConnector();
   332 	Connection conn = cinfo.getConnection();
   337 
   333 
   338 	Set<Instance> instances = null;
   334 	Set<Instance> instances = null;
   339 	MBeanServerConnection mbsc = null;
       
   340 	AggregatorMXBean aggbean = null;
       
   341 
   335 
   342 	try {
   336 	try {
   343 	    ObjectName on =
   337 	    Aggregator aggbean = conn.getObject(new Aggregator());
   344 		new ObjectName("com.oracle.solaris.vp.panel.common.api.smf_old"
       
   345 		    + ":type=Aggregator");
       
   346 	    mbsc = jmxc.getMBeanServerConnection();
       
   347 	    aggbean = RadJMX.newMXBeanProxy(mbsc, on,
       
   348 		AggregatorMXBean.class, Stability.PRIVATE);
       
   349 	    instances = new HashSet<Instance>(aggbean.getinstances());
   338 	    instances = new HashSet<Instance>(aggbean.getinstances());
   350 
   339 
   351 	    for (Instance inst : instances) {
   340 	    for (Instance inst : instances) {
   352 		ServiceManagedObject sobj = new ServiceManagedObject(this,
   341 		ServiceManagedObject sobj = new ServiceManagedObject(this,
   353 		    mbsc, inst);
   342 		    conn, inst);
   354 
   343 
   355 		if (!sobj.isFirewallSupported())
   344 		if (!sobj.isFirewallSupported())
   356 		    continue;
   345 		    continue;
   357 
   346 
   358 		//
   347 		//
   363 		    addManagedServices(sobj);
   352 		    addManagedServices(sobj);
   364 		} else {
   353 		} else {
   365 		    super.addChildren(sobj);
   354 		    super.addChildren(sobj);
   366 		}
   355 		}
   367 	    }
   356 	    }
   368 	} catch (ObjectException e) {
   357 	} catch (RadObjectException e) {
   369 	} catch (IOException e) {
   358 	} catch (IOException e) {
   370 	} catch (MalformedObjectNameException e) {
   359 	} catch (Exception e) {
   371 	} catch (InstanceNotFoundException e) {
       
   372 	} catch (JMException e) {
       
   373 	    throw e; // Propagate proxy creation exception
   360 	    throw e; // Propagate proxy creation exception
   374 	}
   361 	}
   375 
   362 
   376 	Collections.sort(services, SimpleHasId.COMPARATOR);
   363 	Collections.sort(services, SimpleHasId.COMPARATOR);
   377     }
   364     }