My Report

Spring Mock Test 8


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. All errors thrown from Spring Integration components will be a subclass of:-

Question 1 of 10

Question 2 of 10

2. Spring Integration will use that header and forward errors encountered in the processing of this message to that channel.

Question 2 of 10

Question 3 of 10

3. You can configure a Quartz SimpleTrigger object in Spring bean configuration file through:-

Question 3 of 10

Question 4 of 10

4. To register an MBean, you need an instance of the interface :-

import java.lang.management.ManagementFactory;
import javax.management.Descriptor;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.modelmbean.DescriptorSupport;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanInfoSupport;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import javax.management.modelmbean.RequiredModelMBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {<code></code>
	public static void main(String[] args) throws IOException {
		ApplicationContext context =
			new ClassPathXmlApplicationContext("beans-jmx.xml");
		FileReplicator documentReplicator =
		(FileReplicator) context.getBean("documentReplicator");
		try {
			MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
			ObjectName objectName = new ObjectName("bean:name=documentReplicator");
			RequiredModelMBean mbean = new RequiredModelMBean();
			mbean.setManagedResource(documentReplicator, "objectReference");
			Descriptor srcDirDescriptor = new DescriptorSupport(new String[] {
			"name=SrcDir", "descriptorType=attribute",
			"getMethod=getSrcDir", "setMethod=setSrcDir" });
			ModelMBeanAttributeInfo srcDirInfo = new ModelMBeanAttributeInfo(
			"SrcDir", "java.lang.String", "Source directory",
			true, true, false, srcDirDescriptor);
			Descriptor destDirDescriptor = new DescriptorSupport(new String[] {
			"name=DestDir", "descriptorType=attribute",
			"getMethod=getDestDir", "setMethod=setDestDir" });
			public static void main(String[] args) throws IOException {
			ApplicationContext context =
			new ClassPathXmlApplicationContext("beans-jmx.xml");
			FileReplicator documentReplicator =
			(FileReplicator) context.getBean("documentReplicator");
			ModelMBeanAttributeInfo destDirInfo = new ModelMBeanAttributeInfo(
			"DestDir", "java.lang.String", "Destination directory",
			true, true, false, destDirDescriptor);
			ModelMBeanOperationInfo getSrcDirInfo = new ModelMBeanOperationInfo(
			"Get source directory",
			FileReplicator.class.getMethod("getSrcDir"));
			ModelMBeanOperationInfo setSrcDirInfo = new ModelMBeanOperationInfo(
			"Set source directory",
			FileReplicator.class.getMethod("setSrcDir", String.class));
			ModelMBeanOperationInfo getDestDirInfo = new ModelMBeanOperationInfo(
			"Get destination directory",
			FileReplicator.class.getMethod("getDestDir"));
			ModelMBeanOperationInfo setDestDirInfo = new ModelMBeanOperationInfo(
			"Set destination directory",
			FileReplicator.class.getMethod("setDestDir", String.class));
			ModelMBeanOperationInfo replicateInfo = new ModelMBeanOperationInfo(
			"Replicate files",
			FileReplicator.class.getMethod("replicate"));
			ModelMBeanInfo mbeanInfo = new ModelMBeanInfoSupport(
			"FileReplicator", "File replicator",
			new ModelMBeanAttributeInfo[] { srcDirInfo, destDirInfo },
			null,
			new ModelMBeanOperationInfo[] { getSrcDirInfo, setSrcDirInfo,
			getDestDirInfo, setDestDirInfo, replicateInfo },
			null);
			mbean.setModelMBeanInfo(mbeanInfo);
			mbeanServer.registerMBean(mbean, objectName);
			} catch (JMException e) {
			...
			} catch (InvalidTargetObjectTypeException e) {
			...
			} catch (NoSuchMethodException e) {
			...
			}
			System.in.read();
	}
}

Question 4 of 10

Question 5 of 10

5. Sending all the errors to the same channel can eventually lead to a large switch-laden class that’s too complex to maintain.

Question 5 of 10

Question 6 of 10

6. MIME is supported by JavaMail through the:-

Question 6 of 10

Question 7 of 10

7. An adapter is a component that knows how to speak to a specific type of subsystem and translate messages on that subsystem into something that can be used in the Spring Integration bus only.

Question 7 of 10

Question 8 of 10

8. Spring-WS supports annotating an arbitrary class as a service endpoint by:-

Question 8 of 10

Question 9 of 10

9. For correlation when you might not have a size but know that you’re expecting messages that share a common header value within a known time, Spring Integration provides the HeaderAttributeCorrelationStrategy.

Question 9 of 10

Question 10 of 10

10. When you are using XML marshalling, WebServiceTemplate requires both the marshaller and unmarshaller properties to be set.

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.