我的webapp有登录用户.暂停时间.在会话到期之前,我想执行一个方法来清理一些锁.
我实现了一个sessionListener但是一旦我到达public void sessionDestroyed(HttpSessionEvent event)会话已经不见了,我需要一些来自它的数据,所以我想FacesConfig.getCurrentInstance()在会话实际到期之前执行一个方法(需要会话存活并且能够访问).
我怎样才能做到这一点?有任何想法吗?这是我的Session Listener:
public class MySessionListener implements HttpSessionListener {
private static final Logger log = LoggerFactory.getLogger(MySessionListener.class);
public MySessionListener() {
}
public void sessionCreated(HttpSessionEvent event) {
log.debug("Current Session created : "
+ event.getSession().getId()+ " at "+ new Date());
}
public void sessionDestroyed(HttpSessionEvent event) {
// get the destroying session...
HttpSession session = event.getSession();
prepareLogoutInfoAndLogoutActiveUser(session);
log.debug("Current Session destroyed :"
+ session.getId()+ " Logging out user...");
/*
* nobody can reach user data …Run Code Online (Sandbox Code Playgroud) 我想将Jackson用作JAX-RS 2.0 Web服务的JSON提供程序.对于JAX-RS,我在GlassFish 4中使用Jersey 2.0.使用JAX-RS 1.x我可以添加
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
在我的web.xml.我怎么能用Jersey 2.0的Jax-RS 2.0做到这一点?我实现了这样的应用程序类
public class MyRESTExampleApplication extends ResourceConfig {
public MyRESTExampleApplication() {
packages("com.carano.fleet4all.restExample");
register(JacksonFeature.class);
}
}
Run Code Online (Sandbox Code Playgroud)
并将这些行添加到我的web.xml.
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.example.restExample.MyRESTExampleApplication</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
但是我通过请求org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException得到一个例外 :找不到媒体类型= application/json,type = class的MessageBodyWriter ...
我pom.xml看起来像这样
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud) 我在KIE API中需要帮助.需要知道它是什么,是否有任何教程可以使用Drools KIE.是kro的一部分drools-6.x?如果它是drools-6.x的一部分那么使用运行JBPM5.4和guvnor 5.5的Drool-5.5会对应用程序产生什么影响呢?
问候,
扎希德艾哈迈德
在agnular2中是否有api允许传递json对象而不是字符串值.例如,Router.navigate()我可以传递路由参数
Router.navigate('routename',[{key:stringvalue}])
Run Code Online (Sandbox Code Playgroud)
并可以使用RouteParams.get(key) : string.但这只返回字符串值.我需要传递json对象.
感谢任何指针
我有一个自定义周围实现匹配自定义注释.我希望自定义在外部@Transactional中执行.不幸的是,这似乎不起作用.(AOP正在工作.我看到展示它的堆栈跟踪).
堆栈跟踪显示我的AOP执行之前(记录器),MyBatis会话启动事务,MyBatis关闭事务,Spring关闭事务,然后我的AOP完成.
我认为让我的AOP工具Ordered会有所帮助.我将返回的值设置为1.我用过.这没用.我想这是因为我误读了Spring的命令.
建议订购
当多条建议都想在同一个连接点运行时会发生什么?Spring AOP遵循与AspectJ相同的优先级规则来确定建议执行的顺序.最高优先级的建议首先"在路上"(因此,给出两条之前的建议,优先级最高的建议首先运行).从连接点"出路",最高优先级建议最后运行(因此,给出两条后建议,具有最高优先级的建议将运行第二).
当在不同方面定义的两条建议都需要在同一个连接点运行时,除非您另行指定,否则执行顺序是未定义的.您可以通过指定优先级来控制执行顺序.这是通过在方法类中实现org.springframework.core.Ordered接口或使用Order注释对其进行注释来以常规Spring方式完成的.给定两个方面,从Ordered.getValue()(或注释值)返回较低值的方面具有较高的优先级.
当在同一方面定义的两条建议都需要在同一个连接点上运行时,排序是未定义的(因为没有办法通过反射为javac编译的类检索声明顺序).考虑将这些建议方法折叠到每个方面类中每个连接点的一个建议方法中,或者将这些建议重构为单独的方面类 - 可以在方面级别进行排序.
所以我拿出了order属性.这应该使@Transactional返回Integer.MIN_VALUE.因此,如果我理解上面的引用,它应该运行到最后.当我重新部署时,它仍然向后执行.我的AOP,Spring TX,MyBatis,关闭MyBatis,关闭SPring Tx,关闭我的AOP.
我究竟做错了什么?
我已经围绕类型编写了 spring aop 表达式,例如
@Around("execution(* com.mycomp.proj.parent.child1.*.*(..))
|| execution(* com.mycomp.proj.parent.child2.*.*(..))")
Run Code Online (Sandbox Code Playgroud)
但是,如果新包是在父包下创建的,则此表达式将不会应用于新包(e.g.:com.mycomp.proj.parent.child3。如何开发包含这一点并且不适用于直接位于父包中的类的表达式?(只是表达式,只能适用于所有子包中的类)
我正在尝试集成spring和JBPM,我做了谷歌的示例应用程序,发现一个github项目解释相同.
使用的框架版本:
我已经将github项目导入eclipse工作区,并且在maven clean之后我得到例外说:
Listed class "org.jbpm.task.Status" must not be an enum persistence.xml /jbpm-spring-web/src/main/resources/META-INF line 30 JPA Problem
Run Code Online (Sandbox Code Playgroud)
和src/main/resources/META-INF/Taskorm-JPA2.xml文件中的一些JPA查询异常如:
The abstract schema type 'OrganizationalEntity' is unknown. Taskorm-JPA2.xml /jbpm-spring-web/src/main/resources/META-INF line 375 JPA Problem
Run Code Online (Sandbox Code Playgroud)
和
The IN expression does not have a valid left expression. Taskorm-JPA2.xml /jbpm-spring-web/src/main/resources/META-INF line 7 JPA Problem
Run Code Online (Sandbox Code Playgroud)
如何解决这些异常?
persistence.xml看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">
<persistence-unit name="org.jbpm.runtime" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/jbpm-ds</jta-data-source>
<mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file>
<mapping-file>META-INF/ProcessInstanceInfoMapping.xml</mapping-file>
<mapping-file>META-INF/Taskorm-JPA2.xml</mapping-file>
<class>org.jbpm.task.Attachment</class>
<class>org.jbpm.task.Content</class> …Run Code Online (Sandbox Code Playgroud) 我正在春天aop和spring配置文件下面尝试我的手:
<?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"
xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="eddie" class="com.springinaction.Instrumentalist">
<property name="instrument" ref="violin"></property>
<property name="song" value="Samarame"></property>
</bean>
<bean id="kenny" class="com.springinaction.Instrumentalist">
<property name="song" value="SAMARAME "></property>
<property name="instrument" ref="saxopone"></property>
</bean>
<bean id="hank" class="com.springinaction.OneManBand">
<property name="instruments">
<props>
<prop key="GUITAR">STRUM STRUM STRUM</prop>
<prop key="CYMBAL">CRASH CRASH CRASH CRASH</prop>
<prop key="HARMONICA">HUM HUM HUM</prop>
</props>
</property>
</bean>
<bean id="guitar" class="com.springinaction.Guitar">
</bean>
<bean id="violin" class="com.springinaction.Violin">
</bean>
<bean id="tabala" class="com.springinaction.Tabala">
</bean>
<bean id="saxopone" class="com.springinaction.Saxophone">
</bean>
<bean id="audience" class="com.springinaction.Audience"></bean> …Run Code Online (Sandbox Code Playgroud) 我有 2 个对象和地址。人是父母,地址是孩子。
我的存储库正在扩展 JPARepository。
personRepository.save(person);
插入工作正常。但是当我通过更新两个表中的状态(例如:Active)并使用personRepository.save(person);我的外键引用(person_fk)来更新人员对象时,它被设置为空。
我的父类:
@Entity
@DynamicUpdate
@Table(name = "person")
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="person_pk", nullable=false)
private Long personPK;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "person",cascade = CascadeType.PERSIST)
private Set<Address> addresses = new HashSet<>();
...
}
Run Code Online (Sandbox Code Playgroud)
还有我的孩子班:
@Entity
@DynamicUpdate
@Table(name = "address")
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "address_pk")
private Long addressPK;
@ManyToOne
@JoinColumn(name = "person_fk", referencedColumnName = "person_pk", nullable=false)
private Address …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Java 应用程序(这是一个 Web API)中设置一些第三方 appender - appender 是作为依赖项添加的库。这是一个 Maven 应用程序,这些库是 Raven(通过 Sentry)和 Logentries。他们接受日志并提供图形用户界面来查看它们。
本地工作正常 - 当整个应用程序在本地运行时,日志成功显示在 Logentries 和 Sentry 中。在两种环境中都成功找到并解析了配置。我log4j2.xml在为两种环境启动服务器时的配置和输出包含在下面。
在登台环境中,我看到日志说 CLASS_NOT_FOUND,所以这可能是一个类路径问题?有任何想法吗?
配置
<?xml version="1.0" encoding="utf-8"?>
<configuration status="all">
<properties>
<property name="pattern">%d{hh:mm:ss.sss} [mode=${env:MODE}] [%t] %-5level %logger{36} - %msg%n</property>
</properties>
<appenders>
<console name="console" target="system_out">
<patternlayout pattern="${pattern}"/>
</console>
<raven name="sentry">
<dsn>[dsn_here]</dsn>
<patternlayout pattern="${pattern}"/>
<!--to turn down the noise-->
<!--<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>-->
</raven>
<logentries name="le">
<token>[token_here]</token>
<patternlayout pattern="${pattern}"/>
<!--to turn down the noise-->
<!--<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>-->
</logentries>
</appenders> …Run Code Online (Sandbox Code Playgroud)