我真的很喜欢JBoss Seam应用程序框架.由于JSF/EJB/JPA之间的注入/拒绝和紧密集成的概念在Java应用程序框架中相对稀少,因此我一直在寻找一些用于设计模式和使用此框架的最佳实践的良好资源.我已经倾注了关于这个主题的例子和几本书.但是,我对与传统J2EE设计模式相比的实际设计模式更感兴趣.例如,传统DAO与EntityHome/EntityQuery.业务逻辑应该在哪里执行?在Action类中?还是在专门的服务类?我非常感谢Seam开发人员可以提供的任何经验.谢谢!
我正在尝试在我的Seam/Hibernate/JPA应用程序中利用EntityListener对象和回调方法.我在后端使用带有PostgreSQL 9.1的JBoss 5.1上的Seam 2.2管理持久化上下文.我声明了以下实体:
@Entity(name = "TestEntity")
@EntityListeners(TestCallback.class)
@Table(name = "tbl_test")
public class TestEntity implements Serializable {
private static final long serialVersionUID = 2016897066783042092L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "xxx")
@SequenceGenerator(name = "xxx", sequenceName = "xxx")
@Index(name = "xxx")
@DocumentId
private Long id = null;
@Column
private String test = null;
...
}
Run Code Online (Sandbox Code Playgroud)
以及以下EntityListener回调类:
public class TestCallback {
/**
* Logger for this class
*/
private Log logger = null;
public TestCallback() {
logger = Logging.getLog(TestCallback.class);
}
@PrePersist
public …Run Code Online (Sandbox Code Playgroud) 我正在创建一个JSF2 Facelets复合组件.如果定义了特定的facet,我希望HTML的呈现方式不同.有没有办法检查是否<f:facet name="..." />已为复合组件定义了?
我编写了一个简单的RestEasy客户端代理来执行iTunes搜索.它看起来像这样:
@Path("/")
public interface AppleAppStoreLookupClient {
/**
* Attempts to lookup an apple app store item by its ID
*
* @param id
* The item ID
* @return The app details
*/
@GET
@Path("/lookup")
@Produces(value = { "text/javascript" })
public AppleAppDetailsResponse lookupByID(@QueryParam("id") String id);
}
Run Code Online (Sandbox Code Playgroud)
我的JSON模型类也很简单.实际上,对于第一次调用我想要的只是"resultCount"值,只是为了确保连接正常工作.
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class AppleAppDetailsResponse implements Serializable {
private static final long serialVersionUID = 8881587082097337598L;
@XmlElement
private int resultCount = -1;
...getters and setters...
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行一个简单的测试时,我得到以下异常:
org.jboss.resteasy.client.ClientResponseFailure: Unable to find a MessageBodyReader of …Run Code Online (Sandbox Code Playgroud) 我已经实现了一个自定义HttpAuthenticationMechanism子类来使用Soteria/Java EE安全框架提供身份验证.我的身份验证工作正常.但是,我注意到当我调用HttpMessageContext.setRegisterSession(String, Set<String>)创建Java EE时Session,行为不是我所期望的.我期望经过身份验证的身份与网络相关联Session,并且我AuthenticationMechanism的validateRequest(HttpServletRequest req, HttpServletResponse res, HttpMessageContext ctx)方法不会在后续请求中被调用.然而,我观察的是validateRequest(),即使用户已经成功验证,也会在每个请求上调用.
我可以使用@AutoApplySession我的AuthenticationMechanism类上的注释获得我想要的行为,但这不是我想要的行为.我想根据提供的凭证类型选择是否创建会话.
我对setRegisterSession()方法的理解不正确吗?或者这是Soteria中的一个错误?
我们正在Wildfly 8上部署我们的JavaEE 7应用程序.以前,我们已将所有企业应用程序(WAR,多个EJB JAR文件)打包为EAR.但是,JavaEE现在允许您将EJB打包在WAR文件中(或作为WAR的WEB-INF/lib中的JAR),我们想知道部署EAR是否有任何好处,而不是使用WAR打包.
EAR是否提供了WAR不具备的功能?它肯定会降低使用WAR的封装复杂性.部署方面有什么不同吗?EJB命名?什么?
我有一个UIStackView带有 2 个视图的水平视图。我想让左视图占据屏幕的 70% 左右,右视图占据剩余的 30%。我知道我可以将UIStackView对齐设置为 Fill,将分布设置为 Fill,这将使我能够更好地控制我的子视图大小。我想不通的是如何设置布局约束/宽度/等。在子视图上使 70/30 比率正确,尤其是在设备旋转时?
谁能解释如何在我的子视图上设置约束,以便在设备旋转时保持 70/30 的比例?
是否可以在使用Perfect框架开发的服务器端Swift应用程序中利用iOS版Amazon Web Services SDK?我希望能够将我的Perfect应用程序部署到AWS并从该应用程序调用DynamoDB,S3等。但是,我还没有找到任何示例说明是否有可能。即使说“ for iOS”,AWS SDK能否在服务器端使用?它是否支持Swift软件包管理器,Perfect似乎将其用于与第三方库集成?如果不是,Perfect是否支持CocoaPods进行依赖性管理?
如果我尝试可行,还是必须直接使用Amazon的RESTful服务编写自己的集成代码?
我正在尝试使用CoreNLP(Java)对大量产品评论进行情绪分析.总的来说,我发现分析的准确性非常好.从我读到的,我使用的模型最初是使用电影评论创建的(我认为),所以它不是100%适合分析产品评论.我想知道"提高"分析准确性的最佳方法.
我想到的主要是除了产品评论的文本之外,我还有一个用户提供的星级评分.值范围从1-5,1星是最低.我希望有一种方法可以在产生情绪评分时考虑星级评分,因为它更准确地反映了用户对特定产品的感受.有没有一种方法可以最好地将星级评分因子用于CoreNLP中的情绪分析评分?我的分析代码看起来像这样:
List<ProductReview> reviews = this.reviewRepository.findAll();
for (ProductReview review : reviews) {
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref, sentiment");
props.put("ner.model", "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
int starRating = review.getStarRating();
String reviewText = review.getTitle() + " : " + review.getReviewText();
if (!StringUtils.isEmpty(reviewText)) {
int longest = 0;
int mainSentiment = 0;
Annotation annotation = pipeline.process(reviewText);
String sentimentStr = null;
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
Tree sentimentTree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class); …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的本地 Keycloak 8.0.1 实例配置为使用 Google 作为身份提供者。我正在按照我在这里找到的说明进行操作。我已经相应地配置了我的身份提供者、领域和客户端。当我点击登录页面时,我看到了执行 Google 登录的按钮。但是,当我点击它并浏览 Google 同意页面时,我最终被带回 Keycloak 并看到一条错误消息,"We are sorry... Invalid username or password." 在我的 Keycloak 日志中,我看到以下内容:
21:24:26,794 WARN [org.keycloak.services] (default task-25) KC-SERVICES0013: Failed authentication: org.keycloak.authentication.AuthenticationFlowException
at org.keycloak.keycloak-services@8.0.1//org.keycloak.authentication.AuthenticationProcessor.authenticateOnly(AuthenticationProcessor.java:1001)
at org.keycloak.keycloak-services@8.0.1//org.keycloak.services.resources.LoginActionsService$1.authenticateOnly(LoginActionsService.java:769)
at org.keycloak.keycloak-services@8.0.1//org.keycloak.authentication.AuthenticationProcessor.authenticate(AuthenticationProcessor.java:860)
at org.keycloak.keycloak-services@8.0.1//org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:296)
at org.keycloak.keycloak-services@8.0.1//org.keycloak.services.resources.LoginActionsService.brokerLoginFlow(LoginActionsService.java:799)
at org.keycloak.keycloak-services@8.0.1//org.keycloak.services.resources.LoginActionsService.firstBrokerLoginGet(LoginActionsService.java:694)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:517)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:406)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:370)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:356)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:372)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:344)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:137)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:100)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:356) …Run Code Online (Sandbox Code Playgroud)