javaee-samples / javaee7-samples Goto Github PK
View Code? Open in Web Editor NEWJava EE 7 Samples
Home Page: https://travis-ci.org/javaee-samples/javaee7-samples
License: Other
Java EE 7 Samples
Home Page: https://travis-ci.org/javaee-samples/javaee7-samples
License: Other
LoggingInterceptor will not work for MyEndpointWithCDI because Websocket endpoints are not CDI beans (i.e. have different lifecycle).
On my system I get this error from the tests, I assume because I don't have wildfly installed:
org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains a target (wildfly-arquillian) not matching any defined Container in the registry.
Adding Arquillian tests would be a huge win the community, so they could see these working on all the other Java EE 7 containers.
With these and the work we've done at http://www.jboss.org/jdf/quickstarts/get-started/ we have quite a bit of both trivial and non-trival examples for people to use, unfortunately they both seem to be vendor specific :( It would be great to collaborate on making fully impl egnostic examples. Perhaps @pmuir would like to help too?
Faces Flow can be arbitrarily nested, new sample required.
Hi,
I did not find a simple example of using TextStream or BinaryStream. Thus, I am trying to write a simple one to understand them better. The idea is simple. I write annotation based Server and Client Websocket by using Glassfish and Tyrus API. The message is encoded/decoded by using TextStream. When client connect to the server, the server send a JSON object to tell the client its session ID.
Unfortunately, my program does not work :(. But if I use encoder/decoder by Text<>, it works perfectly. I don't understand much about the different configuration for Text and TextStream.
Here are the codes:
ServerEnpoint (WSServer.java) will be exported in WSServer.war
@ServerEndpoint(value = "/test", encoders = {Msg.MsgEncoder.class}, decoders = {Msg.MsgDecoder.class})
public class WSServer{
@OnOpen
public void handleConnection(Session session){
String notification = "New connection : " + session.getId();
System.out.println(notification);
try {
session.getBasicRemote().sendObject(new Msg(notification));
} catch (Exception e) {
e.printStackTrace();
}
}
}
ClientEndpoint (WSClient.java):
@ClientEndpoint(encoders = {Msg.MsgEncoder.class}, decoders = {Msg.MsgDecoder.class})
public class WSClient{
@OnMessage
public void handleMessage(Msg msg){
System.out.println(msg.getMessage());
}
public static void main(String[] args){
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080/WSServer/test";
try {
Session session = container.connectToServer(WSClient.class, URI.create(uri));
while (session.isOpen()) {
Thread.sleep(1000);
session.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Class Msg and its encoder/decoder
public class Msg {
String message;
public Msg(String message) {
super();
this.message = message;
}
public String getMessage() {
return message;
}
public static class MsgEncoder implements Encoder.TextStream<Msg>{
@Override
public void encode(Msg msg, Writer writer) throws EncodeException,IOException {
JsonWriter jWriter = Json.createWriter(writer);
JsonObject jsonObj = Json.createObjectBuilder().add("message", msg.getMessage()).build();
jWriter.writeObject(jsonObj);
}
}
public static class MsgDecoder implements Decoder.TextStream<Msg>{
@Override
public Msg decode(Reader reader) throws DecodeException, IOException {
JsonReader jReader = Json.createReader(reader);
JsonObject jsonObj = jReader.readObject();
String message = jsonObj.getString("message");
Msg msg = new Msg(message);
return msg;
}
}
}
After deploying WSServer.war by GlassFish 4 server, I run WSClient but it does not print anything.
In the same way, instead of using Encoder/Decoder.TextStream<>, I use Encoder/Decoder.Text<>, the client will print the message "New connection : 087c959f-fae2-4d0a-97cb-727ceec6e2e3", which is what I expect to see.
I have been trying to understand the difference between using Text<> and TextStream<> to fix the problem without luck :(. Could you please tell me what I have done incorrectly in my code? Thank you.
Some of the navigations in flow-mixed, flows-declarative, flows-programmatic is not working.
\jaxrs\link\pom.xml
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
Each sample has nb-configuration.xml to define the Java EE server used at runtime. This should be defined at the top-level so that any IDE specific configurations are not defined in each sample.
[ERROR] javaee7-samples-master\jca\connector-simple\connector
\src\main\java\org\javaee7\jca\connector\simple\connector\outbound\MyConnection.
java:[65,8] error: not a statement
Suggestion,
integrate Apache Camel in order to facilitate EE solutions that need to use EIP and deal with a broad range of protocols not supported by a default EE container
Also apache camel has some really nice and remarkable components like
Cloud relative stuff
Amazon cloud component - http://camel.apache.org/aws-cw.html (http://aws.amazon.com/es/cloudwatch/) you can monitor your EC2 and RDS DB instances, and add or remove them dynamically when needed
JClouds component - http://camel.apache.org/jclouds.html . quote "ComputeService simplifies the task of managing machines in the cloud. For example, you can use ComputeService to start 5 machines and install your software on them."
--> I think that jclouds is the defacto standard for Java cloud management, included in Camel, and therefore by using jclouds and some kind of "camel dynamic router builder"(@DynamicRouter), cloud instance governance could be done in an EE container (just and idea)
--> A concrete sample ? Mmmm...thinking
What do you think?
Thanks
J
Add a new sample to show interceptors priority
The samples can now run be run using Cargo. Basic instructions are explained in README.md.
Add a new sample to demonstrate EJB-style interceptors, using @interceptor.
extra\twitter-search\pom.xml
<dependency>
<groupId>org.glassfish.samples</groupId>
<artifactId>twitter-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Giving the following error:
WARNING: StandardWrapperValve[org.javaee7.javamail.definition.AnnotatedEmailServlet]: Servlet.service() for servlet org.javaee7.javamail.definition.AnnotatedEmailServlet threw exception
java.lang.RuntimeException: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qf7sm13437126pac.14 - gsmtp
at org.javaee7.javamail.definition.AnnotatedEmailServlet.processRequest(AnnotatedEmailServlet.java:131)
at org.javaee7.javamail.definition.AnnotatedEmailServlet.doGet(AnnotatedEmailServlet.java:151)
By means of @priority annotation.
See also:
http://docs.jboss.org/cdi/spec/1.1/cdi-spec.html#declaring_selected_alternatives
I've an issue with the chunk-partition sample.
The Glassfish log shows that the ItemWriter is never called.
From the Glassfish batch console, everything seems ok (both batch and exist statuses are COMPLETED).
I'm using GlassFish Server Open Source Edition 4.0 (build 89)
Could you confirm that you have the same behavior?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.