For ejb server I need 2 Files,
- Interface
- Implementation
- Ejb-JAR.xml : META-INF for module Name
# Remote interface
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
package com.kutay.zorlu.ejbremote.server; import java.util.Map; import javax.ejb.Remote; /** * Remote interface for {@link ExampleService}. * @author Kutay Zorlu */ @Remote public interface ExampleService { /** * Greet a name. * @param name name to greet * @return "Hello $name!" */ public String greet(String name); /** * Get the system properties from the server. * @return system properties as map */ public Map<Object, Object> getSystemProperties(); } |
# Implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
package com.kutay.zorlu.ejbremote.server; import java.util.HashMap; import java.util.Map; import javax.ejb.Stateless; /** * Implementation of {@link ExampleService}. * @author Kutay Zorlu * */ @Stateless public class ExampleServiceImpl implements ExampleService { @Override public String greet(String name) { return "Hello " + name + "!"; } @Override public Map<Object, Object> getSystemProperties() { return new HashMap<>(System.getProperties()); } } |
main/resources/META-INF/ejb-jar.xml
1 2 3 4 5 |
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd" version="3.2"> <module-name>ejb-remote-server-kutay</module-name> </ejb-jar> |
pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.kutay.zorlu</groupId> <artifactId>ejb-remote-server-kutay</artifactId> <version>1.0.0</version> <packaging>ejb</packaging> <name>WildFly Example: EJB Remote Server</name> <description>Server-Side EJB for remote EJB example on Wildfly</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- JBoss dependency versions --> <version.jboss.spec.javaee.7.0>1.0.0.Final</version.jboss.spec.javaee.7.0> <!-- other plugin versions --> <version.compiler.plugin>3.1</version.compiler.plugin> <version.ejb.plugin>2.3</version.ejb.plugin> <!-- maven-compiler-plugin --> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.source>1.7</maven.compiler.source> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-7.0</artifactId> <version>${version.jboss.spec.javaee.7.0}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.2_spec</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <!-- Set the name of the deployment --> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${version.compiler.plugin}</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>${version.ejb.plugin}</version> <configuration> <ejbVersion>3.1</ejbVersion> </configuration> </plugin> </plugins> </build> </project> |