Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xin committed Feb 8, 2015
0 parents commit 6223c25
Show file tree
Hide file tree
Showing 244 changed files with 2,592 additions and 0 deletions.
26 changes: 26 additions & 0 deletions springMQ1/springMQ1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="activemq1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat8" level="application_server_libraries" />
</component>
</module>

55 changes: 55 additions & 0 deletions springMQ1/src/activemq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">

<bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"></property>
<property name="destination" ref="messageQueue"></property>
<property name="messageListener" ref="receiveMessageListener"></property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/myJMS/ConnectionFactory"></property>
</bean>
<bean id="messageQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/myJMS/MessageQueue"></property>
</bean>
<bean id="receiveMessageListener"
class="org.shirdrn.spring.jms.integration.ReceiveMessageListener"></bean>

<bean id="messageSender" class="org.shirdrn.spring.jms.integration.MessageSender">
<property name="jmsTemplate" ref="jmsTemplate"></property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"></property>
<property name="defaultDestination" ref="messageQueue"></property>
</bean>

<bean id="sendMessageController"
class="org.shirdrn.spring.jms.integration.SendMessageController">
<property name="messageSender" ref="messageSender" />
<property name="successView" value="/success" />
</bean>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/sendMessage.do">sendMessageController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute" value="rc" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>
58 changes: 58 additions & 0 deletions springMQ1/src/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is the configuring for logging displayed in the Application Server
log4j.rootCategory=DEBUG, stdout

# Replace the line above if you want to put a log file into the directory
# you start Tomcat from
# log4j.rootCategory=INFO, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%t %d{dd/MM HH:mm:ss,SSS} %p [%20.30c{2}]-%L %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender

# You can change this to be an absolute path or even an environment variable
# If you're using an environment variable, you will have to set JAVA_OPTS
# to contain this variables - for example in the catalina.sh or catalina.bat
# file

log4j.appender.R.File=${catalina.home}/logs/euctia.log

log4j.appender.R.MaxFileSize=1000KB

# Don't keep a backup file
log4j.appender.R.MaxBackupIndex=10

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%t %d{dd/MM HH:mm:ss,SSS} %p [%20.30c{2}]-%L %m%n

log4j.logger.com.eucita=DEBUG
log4j.logger.com.eucita.component.acegi=WARN
log4j.logger.com.eucita.utils.GenericsUtils=ERROR

# If programmed properly the most messages would be at DEBUG
# and the least at FATAL.

# Control logging for other open source packages
#log4j.logger.org.apache.commons=ERROR
log4j.logger.org.springframework=DEBUG
log4j.logger.org.acegisecurity=WARN
log4j.logger.org.springframework.transaction=WARN
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=WARN
log4j.logger.java.sql.ResultSet=WARN
log4j.logger.com.atomikos=WARN
#log4j.logger.org.apache.activemq.command.ActiveMQObjectMessage=DEBUG
#log4j.logger.org.springframework.jms.support.converter.MessageConverter=DEBUG
log4j.logger.org.springframework.aop.framework.Cglib2AopProxy=ERROR




Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.shirdrn.spring.jms.integration;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.log4j.Logger;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

public class MessageSender {

private static final Logger LOG = Logger.getLogger(MessageSender.class);
private JmsTemplate jmsTemplate;

public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}

public void sendMessage(final String message) {
LOG.info("Send message: " + message);
jmsTemplate.send(new MessageCreator() {

public Message createMessage(Session session) throws JMSException {
TextMessage textMessage = session.createTextMessage(message);
return textMessage;
}

});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.shirdrn.spring.jms.integration;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.apache.log4j.Logger;

public class ReceiveMessageListener implements MessageListener {

private static final Logger LOG = Logger.getLogger(ReceiveMessageListener.class);

public void onMessage(Message message) {
if (message instanceof TextMessage) {
TextMessage text = (TextMessage) message;
try {
LOG.info("Received message:" + text.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.shirdrn.spring.jms.integration;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class SendMessageController extends MultiActionController {

private String successView;
private MessageSender messageSender;

public ModelAndView sendMessage(HttpServletRequest request,
HttpServletResponse response) throws Exception {

Map<String, Object> retMap = new HashMap<String, Object>();
String message = request.getParameter("message");
messageSender.sendMessage(message);

return new ModelAndView(successView, retMap);
}

public String getSuccessView() {
return successView;
}

public void setSuccessView(String successView) {
this.successView = successView;
}

public MessageSender getMessageSender() {
return messageSender;
}

public void setMessageSender(MessageSender messageSender) {
this.messageSender = messageSender;
}

}
Binary file added springMQ1/web/WEB-INF/lib/activemq-all-5.9.0.jar
Binary file not shown.
Binary file added springMQ1/web/WEB-INF/lib/antlr-2.7.7.jar
Binary file not shown.
Binary file added springMQ1/web/WEB-INF/lib/aopalliance.jar
Binary file not shown.
Binary file not shown.
Binary file added springMQ1/web/WEB-INF/lib/log4j-1.2.17.jar
Binary file not shown.
Binary file added springMQ1/web/WEB-INF/lib/slf4j-log4j12-1.6.6.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
40 changes: 40 additions & 0 deletions springMQ1/web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:activemq.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>controller</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:activemq.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>controller</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
53 changes: 53 additions & 0 deletions springMQ1/web/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css">
-->
</head>

<body>
<div align="center" style="width: 500px; height: 300px; border:2px; borderColor:black">
<form action="sendMessage.do" method="post">
<table align="center">
<tr>
<th colspan="2">
消息发送控制台
</th>
</tr>
<tr>
<td>
消息内容:
</td>
<td>
<input type="text" name="message">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="reset" value="清除">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="发送">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
48 changes: 48 additions & 0 deletions springMQ1/web/success.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css">
-->
</head>

<body>
<div align="center" style="width: 500px; height: 300px; border:2px; borderColor:black">
<form action="sendMessage.do" method="post">
<table align="center">
<tr>
<th colspan="2">
消息发送报告
</th>
</tr>
<tr>
<td colspan="2">
状态:发送成功
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="index.jsp" mce_href="index.jsp">返回</a>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
Loading

0 comments on commit 6223c25

Please sign in to comment.