Configuration Manager Proxy

Autor: Marcin Kasiński
21.01.2011 13:24:00 +0200

Wyświetlanie listy brokerów



	private static void displayBrokerNames(ConfigManagerProxy cmp) 

	{ 

	try 

	{ 

	TopologyProxy topology = cmp.getTopology(); 

	if (topology != null) 

		{ 

		Enumeration allBrokers = topology.getBrokers(null); 

		while (allBrokers.hasMoreElements()) 

		{ 

			BrokerProxy thisBroker = 
			(BrokerProxy) allBrokers.nextElement(); 

			System.out.println("Broker "+
			thisBroker.getName()); 

		} //while

		} //if

	} //try

	catch(ConfigManagerProxyPropertyNotInitializedException ex) 

	{ 

	System.err.println("Comms problem! "+ex); 

	} 

	

	}
	

Usuwa broker



	private static void deleteBroker(ConfigManagerProxy cmp, 
	String brokerName) {

	try {

		TopologyProxy topology = cmp.getTopology();

		if (topology != null) {

		topology.deleteBroker(brokerName);



		} //if

	} //try

	catch (ConfigManagerProxyException ex) {

		System.err.println("Problem! " + ex);

	}

	}



Wyświetlanie listy EG i ich przepływów i MRMów


	private static void displayBrokerEGs(ConfigManagerProxy cmp,

		String brokerName) {

	try {

		TopologyProxy topology = cmp.getTopology();

		if (topology != null) {

		BrokerProxy broker = 
		topology.getBrokerByName(brokerName);



		Enumeration executiongroups = 
		broker.getExecutionGroups(null);



		while (executiongroups.hasMoreElements()) {

			ExecutionGroupProxy executiongroup = 
			(ExecutionGroupProxy) executiongroups

				.nextElement();

			System.out.println("EG-> " + 
			executiongroup.getName());



			Enumeration deployedObjects = 
			executiongroup.getDeployedObjects();



			while (deployedObjects.hasMoreElements()) {

			DeployedObject deployedObject = 
			(DeployedObject) 
			deployedObjects.nextElement();

			System.out.println(deployedObject.getName() 
			+ " " + deployedObject.getFullName());

			} //while

		} //while

		} //if

	} //try

	catch (ConfigManagerProxyPropertyNotInitializedException ex) {

		System.err.println("Comms problem! " + ex);

	}



	}


Wyświetlanie listy ACLi

	private static void displayACLs(ConfigManagerProxy cmp) 

	{ 

	AccessControlEntry[] ace = cmp.getAccessControlEntries(); 

	
	for (int i=0; i<ace.length; i++) 

	{ 

	System.out.println(ace[i].getType() + " " + ace[i].getName() + 

	" has " + ace[i].getPermission()); 

	} 

	}


Dodanie ACL



	private static void createACL(ConfigManagerProxy cmp, 
	String user) {

	AccessControlEntry acls[] = new AccessControlEntry[1];



	AccessControlEntry acl = new AccessControlEntry(user,

		AccessControlEntryPrincipalType.user,

		AccessControlEntryPermission.fullControl);



	acls[0] = acl;



	try {

		cmp.addAccessControlEntries(acls);

	} catch (ConfigManagerProxyLoggedException e) {

	

		e.printStackTrace();

	}

	}



Wyświetlanie listy subskrypcji


	private static void displaySubs(ConfigManagerProxy cmp)
	throws Exception 

	{ 

	String topics = null; 

	// all topics 

	//String brokers = "BROKER%"; 

	String brokers = null;

	// all brokers beginning 'BROKER' 

	String users = null; 

	// all users 

	String subsPoints = null; 

	// all subscriptions points 

	GregorianCalendar start = null; 

	// no start date 

	GregorianCalendar end = new GregorianCalendar(); 

	// to the present 

	SubscriptionsProxy s = cmp.getSubscriptions(topics, brokers, 
	users, subsPoints, start, end); 

	Enumeration elements=s.elements();

	for (Enumeration e = s.elements() ; e.hasMoreElements() ;) 

	{ 

		System.out.println(e.nextElement());

	}

	}



powrót
Zachęcam do przedstawienia swoich uwag i opinii w polu komentarzy.

Komentarze

Dodaj Komentarz