public Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) { if (useProps) { try { return new InitialContext(); } catch (NamingException e) { log.error(e.getMessage()); return null; } } else { return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd); } } public void initConnection(Context ctx, String connfactory, String topic) { try { ConnectionFactory.getTopicConnectionFactory(ctx,connfactory); this.CONN = ConnectionFactory.getTopicConnection(); this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic); this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); this.PUBLISHER = this.SESSION.createPublisher(this.TOPIC); log.info("created the topic connection successfully"); } catch (JMSException e) { log.error("Connection error: " + e.getMessage()); }
public Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) { if (useProps) { try { return new InitialContext(); } catch (NamingException e) { log.error(e.getMessage()); return null; } } else { return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd); } } /** * Create the connection, session and topic subscriber * * @param ctx * @param connfactory * @param topic */ public void initConnection(Context ctx, String connfactory, String topic) { try { ConnectionFactory.getTopicConnectionFactory(ctx,connfactory); this.CONN = ConnectionFactory.getTopicConnection(); this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic); this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); this.SUBSCRIBER = this.SESSION.createSubscriber(this.TOPIC); log.info("created the topic connection successfully"); } catch (JMSException e) { log.error("Connection error: " + e.getMessage()); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jms/client/Publisher.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) {
1
public Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) {
2
		if (useProps) {
2
		if (useProps) {
3
			try {
3
			try {
4
				return new InitialContext();
4
				return new InitialContext();
5
			} catch (NamingException e) {
5
			} catch (NamingException e) {
6
				log.error(e.getMessage());
6
				log.error(e.getMessage());
7
				return null;
7
				return null;
8
			}
8
			}
9
		} else {
9
		} else {
10
			return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd);
10
			return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd);
11
		}
11
		}
12
	}
12
	}
13
	/**
14
	 * Create the connection, session and topic subscriber
15
	 * 
16
	 * @param ctx
17
	 * @param connfactory
18
	 * @param topic
19
	 */
13
	public void initConnection(Context ctx, String connfactory, String topic) {
20
	public void initConnection(Context ctx, String connfactory, String topic) {
14
		try {
21
		try {
15
			ConnectionFactory.getTopicConnectionFactory(ctx,connfactory);
22
			ConnectionFactory.getTopicConnectionFactory(ctx,connfactory);
16
			this.CONN = ConnectionFactory.getTopicConnection();
23
			this.CONN = ConnectionFactory.getTopicConnection();
17
			this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic);
24
			this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic);
18
			this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
25
			this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
19
			this.PUBLISHER = this.SESSION.createPublisher(this.TOPIC);
26
			this.SUBSCRIBER = this.SESSION.createSubscriber(this.TOPIC);
20
			log.info("created the topic connection successfully");
27
			log.info("created the topic connection successfully");
21
		} catch (JMSException e) {
28
		} catch (JMSException e) {
22
			log.error("Connection error: " + e.getMessage());
29
			log.error("Connection error: " + e.getMessage());
23
		}
30
		}
24
	
31
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0