Sandbox-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
January 2011
- 3 participants
- 13 discussions
r462 - in jpa2-validation/trunk/jsr303-validation/src: it/hibernate/src/main/java/org/nuiton/sandbox/jsr303/validation/hibernate main/java/org/nuiton/sandbox/jsr303/validation/services test/java/org/nuiton/sandbox/jsr303/validation test/java/org/nuiton/sandbox/jsr303/validation/services
by fdesbois@users.nuiton.org 14 Jan '11
by fdesbois@users.nuiton.org 14 Jan '11
14 Jan '11
Author: fdesbois
Date: 2011-01-14 14:52:22 +0100 (Fri, 14 Jan 2011)
New Revision: 462
Url: http://nuiton.org/repositories/revision/sandbox/462
Log:
- Add tests for ServiceCustomer
- Add test to check Transactional rollbackFor on non runtime Exception (BusinessException)
Added:
jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BusinessException.java
jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/services/
jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImplTest.java
Modified:
jpa2-validation/trunk/jsr303-validation/src/it/hibernate/src/main/java/org/nuiton/sandbox/jsr303/validation/hibernate/TransactionTest.java
jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomer.java
jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java
Modified: jpa2-validation/trunk/jsr303-validation/src/it/hibernate/src/main/java/org/nuiton/sandbox/jsr303/validation/hibernate/TransactionTest.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/it/hibernate/src/main/java/org/nuiton/sandbox/jsr303/validation/hibernate/TransactionTest.java 2011-01-14 11:20:23 UTC (rev 461)
+++ jpa2-validation/trunk/jsr303-validation/src/it/hibernate/src/main/java/org/nuiton/sandbox/jsr303/validation/hibernate/TransactionTest.java 2011-01-14 13:52:22 UTC (rev 462)
@@ -4,6 +4,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.sandbox.jsr303.validation.services.BusinessException;
import org.nuiton.sandbox.jsr303.validation.services.ServiceCustomer;
import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
import org.nuiton.sandbox.jsr317.jpa2.persistence.CustomerDAO;
@@ -27,10 +28,14 @@
}
public void executeAll() {
- testSaveAgency();
+ try {
+ testSaveAgency();
+ } catch (BusinessException ex) {
+ throw new RuntimeException(ex);
+ }
}
- public void testSaveAgency() {
+ public void testSaveAgency() throws BusinessException {
ServiceCustomer serviceCustomer = context.getBean(ServiceCustomer.class);
CustomerDAO customerDAO = context.getBean(CustomerDAO.class);
Added: jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BusinessException.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BusinessException.java (rev 0)
+++ jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BusinessException.java 2011-01-14 13:52:22 UTC (rev 462)
@@ -0,0 +1,26 @@
+package org.nuiton.sandbox.jsr303.validation.services;
+
+/**
+ * Created on 14/01/11
+ *
+ * @author fdesbois <florian.desbois(a)wiztivi.com>
+ * @version $Id$
+ */
+public class BusinessException extends Exception {
+
+ public BusinessException() {
+ super();
+ }
+
+ public BusinessException(String message) {
+ super(message);
+ }
+
+ public BusinessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BusinessException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomer.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomer.java 2011-01-14 11:20:23 UTC (rev 461)
+++ jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomer.java 2011-01-14 13:52:22 UTC (rev 462)
@@ -12,7 +12,12 @@
*/
public interface ServiceCustomer {
- void saveCustomer(Customer customer) throws ConstraintViolationException;
+ void saveCustomer(Customer customer) throws ConstraintViolationException, BusinessException;
Customer newCustomer();
+
+ int countCustomers();
+
+ void deleteCustomer(Customer customer);
+
}
Modified: jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java 2011-01-14 11:20:23 UTC (rev 461)
+++ jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java 2011-01-14 13:52:22 UTC (rev 462)
@@ -22,17 +22,33 @@
protected CustomerDAO customerDAO;
@Override
- @Transactional(readOnly = false)
- public void saveCustomer(Customer customer) throws ConstraintViolationException {
+ @Transactional(readOnly = false, rollbackFor = BusinessException.class)
+ public void saveCustomer(Customer customer) throws ConstraintViolationException, BusinessException {
checkConstraints(customer);
customerDAO.save(customer);
+
+ if (customer.getFirstName().equals("FAKE")) {
+ throw new BusinessException();
+ }
}
@Override
+ @Transactional(readOnly = false)
+ public void deleteCustomer(Customer customer) {
+ Customer customerToDelete = customerDAO.read(customer.getId());
+ customerDAO.delete(customerToDelete);
+ }
+
+ @Override
public Customer newCustomer() {
return customerDAO.newInstance();
}
+ @Override
+ public int countCustomers() {
+ return customerDAO.count();
+ }
+
}
Added: jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImplTest.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImplTest.java (rev 0)
+++ jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImplTest.java 2011-01-14 13:52:22 UTC (rev 462)
@@ -0,0 +1,90 @@
+package org.nuiton.sandbox.jsr303.validation.services;
+
+import javax.inject.Inject;
+import javax.validation.ConstraintViolationException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.sandbox.jsr303.validation.test.BaseValidationTest;
+import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
+
+/**
+ * Created on 14/01/11
+ *
+ * @author fdesbois <florian.desbois(a)wiztivi.com>
+ * @version $Id$
+ */
+public class ServiceCustomerImplTest extends BaseValidationTest {
+
+ private static final Log log = LogFactory.getLog(ServiceCustomerImplTest.class);
+
+ @Inject
+ private ServiceCustomer serviceCustomer;
+
+ @Test
+ public void testSaveCustomerSuccess() throws Exception {
+
+ // ---- PREPARE DATA ---- //
+
+ Customer customer = serviceCustomer.newCustomer();
+ customer.setFirstName("FIRST_NAME");
+ customer.setLastName("LAST_NAME");
+
+ // ---- EXECUTE ---- //
+
+ serviceCustomer.saveCustomer(customer);
+
+ // ---- CHECK DATA ---- //
+
+ Assert.assertEquals(1, serviceCustomer.countCustomers());
+
+ // ---- CLEAN DATA ---- //
+
+ serviceCustomer.deleteCustomer(customer);
+ }
+
+ @Test(expected = ConstraintViolationException.class)
+ public void testSaveCustomerErrorOnConstraint() throws Exception {
+
+ // ---- PREPARE DATA ---- //
+
+ Customer customer = serviceCustomer.newCustomer();
+
+ // ---- EXECUTE ---- //
+
+ try {
+ serviceCustomer.saveCustomer(customer);
+
+ } finally {
+
+ // ---- CHECK DATA ---- //
+
+ Assert.assertEquals(0, serviceCustomer.countCustomers());
+ }
+ }
+
+ @Test(expected = BusinessException.class)
+ public void testSaveCustomerErrorFake() throws Exception {
+
+ // ---- PREPARE DATA ---- //
+
+ Customer customer = serviceCustomer.newCustomer();
+ customer.setFirstName("FAKE");
+ customer.setLastName("TOTO");
+
+ // ---- EXECUTE ---- //
+
+ try {
+ serviceCustomer.saveCustomer(customer);
+
+ } finally {
+
+ // ---- CHECK DATA ---- //
+
+ Assert.assertEquals(0, serviceCustomer.countCustomers());
+ }
+ }
+
+}
1
0
Author: fdesbois
Date: 2011-01-14 12:20:23 +0100 (Fri, 14 Jan 2011)
New Revision: 461
Url: http://nuiton.org/repositories/revision/sandbox/461
Log:
Use JSR-330 : @Inject instead of @Autowired
Modified:
jpa2-validation/trunk/jsr303-validation/pom.xml
jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BaseService.java
jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java
jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/CustomerValidationTest.java
jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/test/BaseValidationTest.java
jpa2-validation/trunk/jsr317-jpa2/pom.xml
jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/CustomerDAOImpl.java
jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/ModelContextImpl.java
jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/sample/DataSampleProvider.java
jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/test/BaseJpaTest.java
jpa2-validation/trunk/pom.xml
Modified: jpa2-validation/trunk/jsr303-validation/pom.xml
===================================================================
--- jpa2-validation/trunk/jsr303-validation/pom.xml 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr303-validation/pom.xml 2011-01-14 11:20:23 UTC (rev 461)
@@ -62,6 +62,13 @@
<artifactId>validation-api</artifactId>
</dependency>
+ <!-- Injection : JSR-330 -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
<!-- LOGGING -->
<dependency>
<groupId>commons-logging</groupId>
Modified: jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BaseService.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BaseService.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/BaseService.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,6 @@
package org.nuiton.sandbox.jsr303.validation.services;
+import javax.inject.Inject;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
@@ -9,7 +10,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.sandbox.jsr317.jpa2.persistence.ModelContext;
-import org.springframework.beans.factory.annotation.Autowired;
/**
* Created on 28 oct. 2010
@@ -21,10 +21,10 @@
protected final Log logger = LogFactory.getLog(getClass());
- @Autowired
+ @Inject
protected ModelContext modelContext;
- @Autowired
+ @Inject
protected Validator validator;
protected <T> void checkConstraints(T object, Class<?>... groups) throws ConstraintViolationException {
Modified: jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr303-validation/src/main/java/org/nuiton/sandbox/jsr303/validation/services/ServiceCustomerImpl.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,11 +1,11 @@
package org.nuiton.sandbox.jsr303.validation.services;
+import javax.inject.Inject;
+import javax.inject.Named;
import javax.validation.ConstraintViolationException;
import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
import org.nuiton.sandbox.jsr317.jpa2.persistence.CustomerDAO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -14,11 +14,11 @@
* @author fdesbois <florian.desbois(a)wiztivi.com>
* @version $Id$
*/
-@Service
+@Named
@Transactional(readOnly = true)
public class ServiceCustomerImpl extends BaseService implements ServiceCustomer {
- @Autowired
+ @Inject
protected CustomerDAO customerDAO;
@Override
Modified: jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/CustomerValidationTest.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/CustomerValidationTest.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/CustomerValidationTest.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,6 @@
package org.nuiton.sandbox.jsr303.validation;
+import javax.inject.Inject;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.Set;
@@ -12,7 +13,6 @@
import org.nuiton.sandbox.jsr303.validation.test.BaseValidationTest;
import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
import org.nuiton.sandbox.jsr317.jpa2.persistence.CustomerDAO;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -25,7 +25,7 @@
private static final Log log = LogFactory.getLog(CustomerValidationTest.class);
- @Autowired
+ @Inject
protected CustomerDAO userDAO;
@Test
Modified: jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/test/BaseValidationTest.java
===================================================================
--- jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/test/BaseValidationTest.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr303-validation/src/test/java/org/nuiton/sandbox/jsr303/validation/test/BaseValidationTest.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,11 @@
package org.nuiton.sandbox.jsr303.validation.test;
+import javax.inject.Inject;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validator;
+import java.lang.annotation.Annotation;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -8,14 +14,8 @@
import org.nuiton.sandbox.jsr317.jpa2.persistence.ModelContext;
import org.nuiton.sandbox.jsr317.jpa2.sample.DataProviderLimit;
import org.nuiton.sandbox.jsr317.jpa2.test.BaseJpaTest;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
-import javax.validation.Validator;
-import java.lang.annotation.Annotation;
-
/**
* Created on 26 oct. 2010
*
@@ -27,10 +27,10 @@
private static final Log log = LogFactory.getLog(BaseValidationTest.class);
- @Autowired
+ @Inject
protected ModelContext modelContext;
- @Autowired
+ @Inject
protected Validator validator;
protected class ValidationTestRule extends JpaTestRule {
Modified: jpa2-validation/trunk/jsr317-jpa2/pom.xml
===================================================================
--- jpa2-validation/trunk/jsr317-jpa2/pom.xml 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr317-jpa2/pom.xml 2011-01-14 11:20:23 UTC (rev 461)
@@ -76,6 +76,13 @@
<artifactId>hibernate-core</artifactId>
</dependency>
+ <!-- Injection : JSR-330 -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
<!-- LOGGING -->
<dependency>
<groupId>commons-logging</groupId>
Modified: jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/CustomerDAOImpl.java
===================================================================
--- jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/CustomerDAOImpl.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/CustomerDAOImpl.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,12 +1,13 @@
package org.nuiton.sandbox.jsr317.jpa2.persistence;
+import javax.inject.Named;
+
import org.nuiton.sandbox.jsr317.jpa2.entity.AccessCode;
import org.nuiton.sandbox.jsr317.jpa2.entity.AccessCodeImpl;
import org.nuiton.sandbox.jsr317.jpa2.entity.Address;
import org.nuiton.sandbox.jsr317.jpa2.entity.AddressImpl;
import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
import org.nuiton.sandbox.jsr317.jpa2.entity.CustomerImpl;
-import org.springframework.stereotype.Repository;
/**
* Created on 22 oct. 2010
@@ -14,7 +15,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
-@Repository
+@Named
public class CustomerDAOImpl extends BaseDAOImpl<Customer, CustomerImpl> implements CustomerDAO {
public CustomerDAOImpl() {
Modified: jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/ModelContextImpl.java
===================================================================
--- jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/ModelContextImpl.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr317-jpa2/src/main/java/org/nuiton/sandbox/jsr317/jpa2/persistence/ModelContextImpl.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,7 @@
package org.nuiton.sandbox.jsr317.jpa2.persistence;
+import javax.inject.Inject;
+import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.HashMap;
@@ -7,9 +9,7 @@
import org.nuiton.sandbox.jsr317.jpa2.entity.BaseEntity;
import org.nuiton.sandbox.jsr317.jpa2.persistence.BaseDAOImpl.SaveStrategy;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Service;
/**
* Created on 19 nov. 2010
@@ -17,10 +17,10 @@
* @author fdesbois <florian.desbois(a)wiztivi.com>
* @version $Id$
*/
-@Service
+@Named
public class ModelContextImpl implements ModelContext {
- @Autowired
+ @Inject
protected ApplicationContext context;
@PersistenceContext
Modified: jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/sample/DataSampleProvider.java
===================================================================
--- jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/sample/DataSampleProvider.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/sample/DataSampleProvider.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,7 @@
package org.nuiton.sandbox.jsr317.jpa2.sample;
+import javax.inject.Inject;
+import javax.inject.Named;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@@ -8,24 +10,23 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.sandbox.jsr317.jpa2.entity.Customer;
import org.nuiton.sandbox.jsr317.jpa2.persistence.CustomerDAO;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Provider of data sample usefull for tests or having usable data in the database. Defined as a {@link Service} to be injected using Spring
- * {@link Autowired} annotation.
+ * {@link Inject} annotation.
* <p />
* Created on 3 nov. 2010
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
-@Service
+@Named
public class DataSampleProvider {
private static final Log logger = LogFactory.getLog(DataSampleProvider.class);
- @Autowired
+ @Inject
protected CustomerDAO customerDAO;
protected List<Customer> customers = new ArrayList<Customer>();
Modified: jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/test/BaseJpaTest.java
===================================================================
--- jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/test/BaseJpaTest.java 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/jsr317-jpa2/src/test/java/org/nuiton/sandbox/jsr317/jpa2/test/BaseJpaTest.java 2011-01-14 11:20:23 UTC (rev 461)
@@ -1,5 +1,9 @@
package org.nuiton.sandbox.jsr317.jpa2.test;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Rule;
@@ -10,14 +14,10 @@
import org.nuiton.sandbox.jsr317.jpa2.sample.DataProviderLimit;
import org.nuiton.sandbox.jsr317.jpa2.sample.DataSampleProvider;
import org.nuiton.sandbox.jsr317.jpa2.sample.UseDataProvider;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
/**
* Created on 18 oct. 2010
*
@@ -30,16 +30,16 @@
private static final Log log = LogFactory.getLog(BaseJpaTest.class);
- @Autowired
+ @Inject
protected ApplicationContext context;
@PersistenceContext
protected EntityManager entityManager;
- @Autowired
+ @Inject
protected DataSampleProvider dataProvider;
- @Autowired
+ @Inject
protected CustomerDAO userDAO;
protected class JpaTestRule extends TestWatchman {
Modified: jpa2-validation/trunk/pom.xml
===================================================================
--- jpa2-validation/trunk/pom.xml 2011-01-12 13:52:52 UTC (rev 460)
+++ jpa2-validation/trunk/pom.xml 2011-01-14 11:20:23 UTC (rev 461)
@@ -77,7 +77,7 @@
<version>${springVersion}</version>
</dependency>
- <!-- JPA : JSR-317- -->
+ <!-- Persistence : JSR-317- -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
@@ -91,20 +91,20 @@
<scope>provided</scope>
</dependency>
+ <!-- Validation : JSR-303 -->
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${hibernateVersion}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Bean Validation : JSR-303 -->
- <dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validationApiVersion}</version>
</dependency>
+ <!-- Injection : JSR-330 -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
<!-- LOGGING -->
<dependency>
<groupId>log4j</groupId>
@@ -131,6 +131,13 @@
<dependency>
<groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${hibernateVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernateValidatorVersion}</version>
<scope>test</scope>
1
0
r460 - in testStandaloneRmi: . src/main/java/org/nuiton/sandbox src/main/java/org/nuiton/sandbox/rmi src/test/java/org/nuiton/sandbox src/test/java/org/nuiton/sandbox/business src/test/java/org/nuiton/sandbox/rmi
by athimel@users.nuiton.org 12 Jan '11
by athimel@users.nuiton.org 12 Jan '11
12 Jan '11
Author: athimel
Date: 2011-01-12 14:52:52 +0100 (Wed, 12 Jan 2011)
New Revision: 460
Url: http://nuiton.org/repositories/revision/sandbox/460
Log:
Prepare implementation for another project's integration
Added:
testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/
testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceImpl.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java
Removed:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/
testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java
Modified:
testStandaloneRmi/pom.xml
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java
Modified: testStandaloneRmi/pom.xml
===================================================================
--- testStandaloneRmi/pom.xml 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/pom.xml 2011-01-12 13:52:52 UTC (rev 460)
@@ -8,5 +8,20 @@
<artifactId>sandbox-rmi</artifactId>
<version>1.0</version>
-
+ <dependencies>
+
+ <dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-api</artifactId>
+ <version>3.0.3-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ </dependencies>
+
</project>
\ No newline at end of file
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -4,10 +4,23 @@
import java.rmi.RemoteException;
/**
+ * This class will act as an InvocationHandler except that it is distributed.
+ *
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
public interface RemoteMethodExecutor extends Remote {
- public abstract Object execute(String methodName, Class<?>[] parametersType, Object[] args) throws RemoteException;
+ /**
+ * Acts like an InvocationHandler.
+ *
+ * @param methodName name of the method to invoke
+ * @param parametersType parameters type to reliably identify the method
+ * @param args method arguments to process the effective call
+ * @return the result of the delegate method
+ * @throws RemoteException for any error. Business exceptions will be
+ * wrapped.
+ */
+ Object execute(String methodName, Class<?>[] parametersType, Object[] args)
+ throws RemoteException;
}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -1,15 +1,30 @@
package org.nuiton.sandbox.rmi;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.rmi.RemoteException;
/**
+ * RMI implementation of an invocation handler. This object will be exported to
+ * a RMI registry and will delegate method calls to some business service. The
+ * service is provided in the constructor.
+ *
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
public class RemoteMethodExecutorImpl<T> implements RemoteMethodExecutor {
+ /**
+ * The target service on which calls will be made
+ */
protected T service;
+ /**
+ * This is the only available constructor. It is mandatory to specify a
+ * target service on which call will be
+ * delegated.
+ *
+ * @param service the mandatory service which calls will be delegated on
+ */
public RemoteMethodExecutorImpl(T service) {
if (service == null) {
throw new NullPointerException("Service cannot be null");
@@ -18,14 +33,29 @@
}
@Override
- public Object execute(String methodName, Class<?>[] parametersType, Object[] args) throws RemoteException {
+ public Object execute(
+ String methodName, Class<?>[] parametersType, Object[] args)
+ throws RemoteException {
+
Object result;
try {
- Method method = service.getClass().getMethod(methodName, parametersType);
+
+ // Get the method on the target service then invoke it
+ Method method = service.getClass().getMethod(
+ methodName, parametersType);
result = method.invoke(service, args);
- } catch (Exception eee) {
- throw new RemoteException("Unable to delegate method call to service", eee);
+
+ } catch (InvocationTargetException ite) {
+ // This is the normal behaviour if a business exception is thrown
+ Throwable targetException = ite.getTargetException();
+ throw new RemoteException(
+ "Business exception occurred", targetException);
+ } catch (NoSuchMethodException nsme) {
+ throw new RemoteException("Delegate method not found", nsme);
+ } catch (IllegalAccessException iae) {
+ throw new RemoteException("Delegate method not accessible", iae);
}
+
return result;
}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -1,44 +1,108 @@
package org.nuiton.sandbox.rmi;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.ServerException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
+ * Factory to create RMI proxies to some given services.
+ *
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
public class RemoteProxyFactory {
+ private final static Log log = LogFactory.getLog(RemoteProxyFactory.class);
+
+ // TODO AThimel 12/01/2011 This settings has to be externalized
protected final static int PORT = 12345;
+ protected final static String REGISTRY_IP = "10.1.1.85";
- protected static <T> T createProxy(final Class<T> serviceInterface) throws Exception {
+ /**
+ * Create a RMI proxy on the wanted service interface. The default RMI name
+ * will be used to find this service in the Registry.
+ *
+ * @param serviceInterface The class of the service proxy to create
+ * @param <T> some interface class
+ * @return A newly created proxy which interface is <T>
+ * @throws RemoteException in case the registry is not reachable
+ * @throws NotBoundException if the default RMI name cannot be found in the
+ * registry
+ */
+ public static <T> T createProxy(final Class<T> serviceInterface)
+ throws RemoteException, NotBoundException {
+
+ // The default RMI name will be the FQN of the service interface
String rmiName = serviceInterface.getName();
T result = createProxy(rmiName, serviceInterface);
+
return result;
}
- protected static <T> T createProxy(String rmiName, final Class<T> serviceInterface) throws Exception {
+ /**
+ * Create a RMI proxy on the wanted service interface. The specific given
+ * RMI name will be used to find this service in the Registry.
+ *
+ * @param rmiName The specific RMI name to use to find the service
+ * in the registry
+ * @param serviceInterface The class of the service proxy to create
+ * @param <T> some interface class
+ * @return A newly created proxy which interface is <T>
+ * @throws RemoteException in case the registry is not reachable
+ * @throws NotBoundException if the default RMI name cannot be found in the
+ * registry
+ */
+ public static <T> T createProxy(String rmiName, Class<T> serviceInterface)
+ throws RemoteException, NotBoundException {
- Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
- final RemoteMethodExecutor stub = (RemoteMethodExecutor) registry.lookup(rmiName);
+ // Lookup the registry and the remote executor from the registry
+ Registry registry = LocateRegistry.getRegistry(REGISTRY_IP, PORT);
+ final RemoteMethodExecutor stub =
+ (RemoteMethodExecutor) registry.lookup(rmiName);
InvocationHandler handler = new InvocationHandler() {
@Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ // Get parameters types and values to prepare delegate call
String methodName = method.getName();
Class<?>[] parametersType = method.getParameterTypes();
- Object result = stub.execute(methodName, parametersType, args);
+ // Delegate the execution and manage business exception cases
+ Object result;
+ try {
+ result = stub.execute(methodName, parametersType, args);
+ } catch (ServerException se) {
+ if (log.isInfoEnabled()) {
+ log.info("Server exception: " + se.getMessage());
+ }
+ Throwable cause = se.getCause();
+ if (cause instanceof RemoteException) {
+ RemoteException re = (RemoteException) cause;
+ cause = re.getCause();
+ }
+ throw cause;
+ }
return result;
}
};
- T proxy = (T) Proxy.newProxyInstance(ServiceExporter.class.getClassLoader(), new Class<?>[]{serviceInterface}, handler);
+
+ // Invocation handler is ready, now create the proxy
+ T proxy = (T) Proxy.newProxyInstance(
+ ServiceExporter.class.getClassLoader(),
+ new Class<?>[]{serviceInterface},
+ handler);
+
return proxy;
}
-
}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -1,5 +1,8 @@
package org.nuiton.sandbox.rmi;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.rmi.ConnectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
@@ -8,42 +11,85 @@
import java.rmi.server.UnicastRemoteObject;
/**
+ * This class allows to make some service available throw RMI. For each service,
+ * a wrapper will be created which will be put in the RMI registry. This wrapper
+ * will intercept calls to the service and delegate them to it.
+ *
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
public class ServiceExporter {
+ private final static Log log = LogFactory.getLog(ServiceExporter.class);
+
+ // TODO AThimel 12/01/2011 This settings has to be externalized
private static final int PORT = 12345;
+ /**
+ * Does some checks on RMI configuration
+ */
protected void testRmiConfig() {
String rmiHost = System.getProperty("java.rmi.server.hostname");
- if (rmiHost == null || "".equals(rmiHost.trim())) {
- System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
+ if ((rmiHost == null || "".equals(rmiHost.trim()))
+ && log.isWarnEnabled()) {
+ log.warn("Server might not have been initialized properly, " +
+ "please specify '-Djava.rmi.server.hostname=<IP-address>'");
}
}
+ /**
+ * Will look for the RMI registry. It an external registry cannot be found,
+ * a new one will be created.
+ *
+ * @return the registry found or created
+ * @throws RemoteException in case it is not possible to get the registry
+ */
protected Registry getRegistry() throws RemoteException {
Registry result;
try {
result = LocateRegistry.getRegistry(PORT);
- result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
+ // To test that registry has been created. An exception will be
+ // thrown if registry cannot be called
+ result.list();
} catch (ConnectException ce) {
- System.err.println("Registry not found, creating a new one");
+ if (log.isWarnEnabled()) {
+ log.warn("Registry not found, creating a new one");
+ }
result = LocateRegistry.createRegistry(PORT);
}
return result;
}
- public <E> void registerService(Class<E> serviceInterface, E instance) throws RemoteException {
+ /**
+ * Will register a service using the default name.
+ *
+ * @param serviceInterface the interface used to bind the service. The RMI
+ * name will be generated from this class name
+ * @param instance the service instance to bind
+ * @param <E> some interface class
+ * @throws RemoteException in case the registry is not reachable
+ */
+ public <E> void registerService(Class<E> serviceInterface, E instance)
+ throws RemoteException {
String rmiName = serviceInterface.getName();
registerService(rmiName, instance);
}
- public <E> void registerService(String rmiName, E instance) throws RemoteException {
+ /**
+ * Will register a service using the given RMI name.
+ *
+ * @param rmiName the RMI name used to bind the service in the registry
+ * @param instance the service instance to bind
+ * @param <E> some interface class
+ * @throws RemoteException in case the registry is not reachable
+ */
+ public <E> void registerService(String rmiName, E instance)
+ throws RemoteException {
testRmiConfig();
// Create the proxy and let him be a stub
- RemoteMethodExecutorImpl<E> executor = new RemoteMethodExecutorImpl<E>(instance);
+ RemoteMethodExecutorImpl<E> executor =
+ new RemoteMethodExecutorImpl<E>(instance);
Remote stub = UnicastRemoteObject.exportObject(executor, 0);
// Bind into the registry
Copied: testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceImpl.java (from rev 459, testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java)
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceImpl.java (rev 0)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -0,0 +1,37 @@
+package org.nuiton.sandbox.business;
+
+import org.nuiton.wikitty.entities.Wikitty;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceImpl implements ServiceInterface {
+
+ protected static final int number = (int) (Math.random() * 100);
+
+ @Override
+ public String testExchange(String whoIsCalling, int intValue) {
+ System.out.println(String.format("Incoming call from %s with value: (%d). To guess: (%d)", whoIsCalling, intValue, number));
+ String result;
+ if (intValue == number) {
+ result = String.format("Congrats %s, you found the correct number : '%d' !", whoIsCalling, intValue);
+ } else if (intValue < number) {
+ result = String.format("%s, your number is too low : '%d'", whoIsCalling, intValue);
+ } else {
+ result = String.format("%s, your number is too high : '%d'", whoIsCalling, intValue);
+ }
+ return result;
+ }
+
+ @Override
+ public void testException() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+
+ @Override
+ public Wikitty testComplexObject(Wikitty in) throws CloneNotSupportedException {
+ Wikitty out = in.clone();
+ return out;
+ }
+
+}
Deleted: testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-11 10:52:23 UTC (rev 455)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -1,7 +0,0 @@
-package org.nuiton.sandbox.business;
-
-public interface ServiceInterface {
-
- public abstract String testExchange(Integer intValue);
-
-}
Copied: testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java (from rev 457, testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java)
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java (rev 0)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -0,0 +1,16 @@
+package org.nuiton.sandbox.business;
+
+import org.nuiton.wikitty.entities.Wikitty;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public interface ServiceInterface {
+
+ String testExchange(String whoIsCalling, int intValue);
+
+ void testException() throws CloneNotSupportedException;
+
+ Wikitty testComplexObject(Wikitty in) throws CloneNotSupportedException;
+
+}
Modified: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java 2011-01-12 09:52:53 UTC (rev 459)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java 2011-01-12 13:52:52 UTC (rev 460)
@@ -1,6 +1,8 @@
package org.nuiton.sandbox.rmi;
import org.nuiton.sandbox.business.ServiceInterface;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.entities.WikittyImpl;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -20,6 +22,18 @@
ServiceInterface service = RemoteProxyFactory.createProxy(ServiceInterface.class);
String result = service.testExchange(System.getProperty("user.name"), 50);
System.out.println(result);
+
+ try {
+ service.testException();
+ } catch (CloneNotSupportedException cnse) {
+ System.err.println("Ok!");
+ }
+
+ Wikitty in = new WikittyImpl();
+ in.setFqField("toto.titi", 999L);
+ Wikitty out = service.testComplexObject(in);
+ assert out.equals(in);
+
}
}
1
0
r459 - in testStandaloneRmi/src/main/java/org/nuiton/sandbox: business rmi
by athimel@users.nuiton.org 12 Jan '11
by athimel@users.nuiton.org 12 Jan '11
12 Jan '11
Author: athimel
Date: 2011-01-12 10:52:53 +0100 (Wed, 12 Jan 2011)
New Revision: 459
Url: http://nuiton.org/repositories/revision/sandbox/459
Log:
Format code / organize imports
Modified:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 09:38:21 UTC (rev 458)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 09:52:53 UTC (rev 459)
@@ -5,7 +5,7 @@
*/
public class ServiceImpl implements ServiceInterface {
- protected static final int number = (int)(Math.random() * 100);
+ protected static final int number = (int) (Math.random() * 100);
@Override
public String testExchange(String whoIsCalling, Integer intValue) {
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java 2011-01-12 09:38:21 UTC (rev 458)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java 2011-01-12 09:52:53 UTC (rev 459)
@@ -3,7 +3,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@@ -23,7 +22,7 @@
protected static <T> T createProxy(String rmiName, final Class<T> serviceInterface) throws Exception {
Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
- final RemoteMethodExecutor stub = (RemoteMethodExecutor)registry.lookup(rmiName);
+ final RemoteMethodExecutor stub = (RemoteMethodExecutor) registry.lookup(rmiName);
InvocationHandler handler = new InvocationHandler() {
@Override
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:38:21 UTC (rev 458)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:52:53 UTC (rev 459)
@@ -1,12 +1,5 @@
package org.nuiton.sandbox.rmi;
-import org.nuiton.sandbox.business.ServiceImpl;
-import org.nuiton.sandbox.business.ServiceInterface;
-import sun.security.jca.ServiceId;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.rmi.ConnectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
1
0
r458 - in testStandaloneRmi/src: main/java/org/nuiton/sandbox/business main/java/org/nuiton/sandbox/rmi test/java/org/nuiton/sandbox/rmi
by athimel@users.nuiton.org 12 Jan '11
by athimel@users.nuiton.org 12 Jan '11
12 Jan '11
Author: athimel
Date: 2011-01-12 10:38:21 +0100 (Wed, 12 Jan 2011)
New Revision: 458
Url: http://nuiton.org/repositories/revision/sandbox/458
Log:
Implement a client side proxy
Added:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ServiceExporterMain.java
Removed:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
Modified:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -5,10 +5,19 @@
*/
public class ServiceImpl implements ServiceInterface {
+ protected static final int number = (int)(Math.random() * 100);
+
@Override
public String testExchange(String whoIsCalling, Integer intValue) {
- System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
- String result = String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
+ System.out.println(String.format("Incoming call from %s with value: (%d). To guess: (%d)", whoIsCalling, intValue, number));
+ String result;
+ if (intValue == number) {
+ result = String.format("Congrats %s, you found the correct number : '%d' !", whoIsCalling, intValue);
+ } else if (intValue < number) {
+ result = String.format("%s, your number is too low : '%d'", whoIsCalling, intValue);
+ } else {
+ result = String.format("%s, your number is too high : '%d'", whoIsCalling, intValue);
+ }
return result;
}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteProxyFactory.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -0,0 +1,45 @@
+package org.nuiton.sandbox.rmi;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class RemoteProxyFactory {
+
+ protected final static int PORT = 12345;
+
+ protected static <T> T createProxy(final Class<T> serviceInterface) throws Exception {
+ String rmiName = serviceInterface.getName();
+ T result = createProxy(rmiName, serviceInterface);
+ return result;
+ }
+
+ protected static <T> T createProxy(String rmiName, final Class<T> serviceInterface) throws Exception {
+
+ Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
+ final RemoteMethodExecutor stub = (RemoteMethodExecutor)registry.lookup(rmiName);
+
+ InvocationHandler handler = new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ String methodName = method.getName();
+ Class<?>[] parametersType = method.getParameterTypes();
+
+ Object result = stub.execute(methodName, parametersType, args);
+
+ return result;
+ }
+ };
+ T proxy = (T) Proxy.newProxyInstance(ServiceExporter.class.getClassLoader(), new Class<?>[]{serviceInterface}, handler);
+ return proxy;
+ }
+
+
+}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -40,8 +40,13 @@
return result;
}
- public <E> void registerService(E instance, String name) throws RemoteException {
+ public <E> void registerService(Class<E> serviceInterface, E instance) throws RemoteException {
+ String rmiName = serviceInterface.getName();
+ registerService(rmiName, instance);
+ }
+ public <E> void registerService(String rmiName, E instance) throws RemoteException {
+
testRmiConfig();
// Create the proxy and let him be a stub
@@ -50,12 +55,7 @@
// Bind into the registry
Registry registry = getRegistry();
- registry.rebind(name, stub);
+ registry.rebind(rmiName, stub);
}
- public static void main(String[] args) throws Exception {
- new ServiceExporter().registerService(new ServiceImpl(), "toto");
- System.err.println("Service2 ready");
- }
-
}
Deleted: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -1,58 +0,0 @@
-package org.nuiton.sandbox.rmi;
-
-import java.rmi.ConnectException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-
-/**
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- */
-public class ServiceRMIImpl implements ServiceRMIInterface {
-
- private static final int PORT = 12345;
-
- public ServiceRMIImpl() {
- }
-
- public static void main(String[] args) throws Exception {
-
- testRmiConfig();
-
- ServiceRMIImpl impl = new ServiceRMIImpl();
- Remote stub = UnicastRemoteObject.exportObject(impl, 0);
-
- Registry registry = getRegistry();
- registry.bind("MyService", stub);
-
- System.err.println("Service ready");
- }
-
- protected static void testRmiConfig() {
- String rmiHost = System.getProperty("java.rmi.server.hostname");
- if (rmiHost == null || "".equals(rmiHost.trim())) {
- System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
- }
- }
-
- protected static Registry getRegistry() throws RemoteException {
- Registry result;
- try {
- result = LocateRegistry.getRegistry(PORT);
- result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
- } catch (ConnectException ce) {
- System.err.println("Registry not found, creating a new one");
- result = LocateRegistry.createRegistry(PORT);
- }
- return result;
- }
-
- @Override
- public String testExchange(String whoIsCalling, Integer intValue) throws RemoteException {
- System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
- return String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
- }
-
-}
Deleted: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -1,15 +0,0 @@
-package org.nuiton.sandbox.rmi;
-
-import org.nuiton.sandbox.business.ServiceInterface;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-/**
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- */
-public interface ServiceRMIInterface extends Remote {
-
- public abstract String testExchange(String whoIsCalling, Integer intValue) throws RemoteException;
-
-}
Deleted: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -1,19 +0,0 @@
-package org.nuiton.sandbox.rmi;
-
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-
-/**
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- */
-public class Client {
-
- private static final int PORT = 12345;
- public static void main(String[] args) throws Exception {
- Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
- ServiceRMIInterface stub = (ServiceRMIInterface) registry.lookup("MyService");
- String response = stub.testExchange(System.getProperty("user.name"), 123);
- System.out.println("response: " + response);
- }
-
-}
Modified: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java 2011-01-12 09:12:32 UTC (rev 457)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -16,12 +16,9 @@
*/
public class ClientExporter {
- private static final int PORT = 12345;
public static void main(String[] args) throws Throwable {
- Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
- RemoteMethodExecutor stub = (RemoteMethodExecutor)registry.lookup("toto");
-
- Object result = stub.execute("testExchange", new Class<?>[]{String.class, Integer.class}, new Object[] {System.getProperty("user.name"), 123});
+ ServiceInterface service = RemoteProxyFactory.createProxy(ServiceInterface.class);
+ String result = service.testExchange(System.getProperty("user.name"), 50);
System.out.println(result);
}
Added: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ServiceExporterMain.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ServiceExporterMain.java (rev 0)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ServiceExporterMain.java 2011-01-12 09:38:21 UTC (rev 458)
@@ -0,0 +1,16 @@
+package org.nuiton.sandbox.rmi;
+
+import org.nuiton.sandbox.business.ServiceImpl;
+import org.nuiton.sandbox.business.ServiceInterface;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceExporterMain {
+
+ public static void main(String[] args) throws Exception {
+ new ServiceExporter().registerService(ServiceInterface.class, new ServiceImpl());
+ System.err.println("Service is ready, waiting for incoming calls");
+ }
+
+}
1
0
r457 - in testStandaloneRmi/src: main/java/org/nuiton/sandbox/business main/java/org/nuiton/sandbox/rmi test/java/org/nuiton/sandbox/rmi
by athimel@users.nuiton.org 12 Jan '11
by athimel@users.nuiton.org 12 Jan '11
12 Jan '11
Author: athimel
Date: 2011-01-12 10:12:32 +0100 (Wed, 12 Jan 2011)
New Revision: 457
Url: http://nuiton.org/repositories/revision/sandbox/457
Log:
First Exporter implem
Added:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java
Removed:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
Modified:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceImpl.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,15 @@
+package org.nuiton.sandbox.business;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceImpl implements ServiceInterface {
+
+ @Override
+ public String testExchange(String whoIsCalling, Integer intValue) {
+ System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
+ String result = String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
+ return result;
+ }
+
+}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-11 13:05:58 UTC (rev 456)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -1,7 +1,10 @@
package org.nuiton.sandbox.business;
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
public interface ServiceInterface {
- public abstract String testExchange(Integer intValue);
+ public abstract String testExchange(String whoIsCalling, Integer intValue);
}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutor.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,13 @@
+package org.nuiton.sandbox.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public interface RemoteMethodExecutor extends Remote {
+
+ public abstract Object execute(String methodName, Class<?>[] parametersType, Object[] args) throws RemoteException;
+
+}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/RemoteMethodExecutorImpl.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,32 @@
+package org.nuiton.sandbox.rmi;
+
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class RemoteMethodExecutorImpl<T> implements RemoteMethodExecutor {
+
+ protected T service;
+
+ public RemoteMethodExecutorImpl(T service) {
+ if (service == null) {
+ throw new NullPointerException("Service cannot be null");
+ }
+ this.service = service;
+ }
+
+ @Override
+ public Object execute(String methodName, Class<?>[] parametersType, Object[] args) throws RemoteException {
+ Object result;
+ try {
+ Method method = service.getClass().getMethod(methodName, parametersType);
+ result = method.invoke(service, args);
+ } catch (Exception eee) {
+ throw new RemoteException("Unable to delegate method call to service", eee);
+ }
+ return result;
+ }
+
+}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceExporter.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,61 @@
+package org.nuiton.sandbox.rmi;
+
+import org.nuiton.sandbox.business.ServiceImpl;
+import org.nuiton.sandbox.business.ServiceInterface;
+import sun.security.jca.ServiceId;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.ConnectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceExporter {
+
+ private static final int PORT = 12345;
+
+ protected void testRmiConfig() {
+ String rmiHost = System.getProperty("java.rmi.server.hostname");
+ if (rmiHost == null || "".equals(rmiHost.trim())) {
+ System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
+ }
+ }
+
+ protected Registry getRegistry() throws RemoteException {
+ Registry result;
+ try {
+ result = LocateRegistry.getRegistry(PORT);
+ result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
+ } catch (ConnectException ce) {
+ System.err.println("Registry not found, creating a new one");
+ result = LocateRegistry.createRegistry(PORT);
+ }
+ return result;
+ }
+
+ public <E> void registerService(E instance, String name) throws RemoteException {
+
+ testRmiConfig();
+
+ // Create the proxy and let him be a stub
+ RemoteMethodExecutorImpl<E> executor = new RemoteMethodExecutorImpl<E>(instance);
+ Remote stub = UnicastRemoteObject.exportObject(executor, 0);
+
+ // Bind into the registry
+ Registry registry = getRegistry();
+ registry.rebind(name, stub);
+ }
+
+ public static void main(String[] args) throws Exception {
+ new ServiceExporter().registerService(new ServiceImpl(), "toto");
+ System.err.println("Service2 ready");
+ }
+
+}
Deleted: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java 2011-01-11 13:05:58 UTC (rev 456)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -1,58 +0,0 @@
-package org.nuiton.sandbox.rmi;
-
-import java.rmi.ConnectException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-
-/**
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- */
-public class ServiceImpl implements ServiceRMIInterface {
-
- private static final int PORT = 12345;
-
- public ServiceImpl() {
- }
-
- public static void main(String[] args) throws Exception {
-
- testRmiConfig();
-
- ServiceImpl impl = new ServiceImpl();
- Remote stub = UnicastRemoteObject.exportObject(impl, 0);
-
- Registry registry = getRegistry();
- registry.bind("MyService", stub);
-
- System.err.println("Service ready");
- }
-
- protected static void testRmiConfig() {
- String rmiHost = System.getProperty("java.rmi.server.hostname");
- if (rmiHost == null || "".equals(rmiHost.trim())) {
- System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
- }
- }
-
- protected static Registry getRegistry() throws RemoteException {
- Registry result;
- try {
- result = LocateRegistry.getRegistry(PORT);
- result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
- } catch (ConnectException ce) {
- System.err.println("Registry not found, creating a new one");
- result = LocateRegistry.createRegistry(PORT);
- }
- return result;
- }
-
- @Override
- public String testExchange(String whoIsCalling, Integer intValue) throws RemoteException {
- System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
- return String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
- }
-
-}
Copied: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java (from rev 456, testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java)
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIImpl.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,58 @@
+package org.nuiton.sandbox.rmi;
+
+import java.rmi.ConnectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceRMIImpl implements ServiceRMIInterface {
+
+ private static final int PORT = 12345;
+
+ public ServiceRMIImpl() {
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ testRmiConfig();
+
+ ServiceRMIImpl impl = new ServiceRMIImpl();
+ Remote stub = UnicastRemoteObject.exportObject(impl, 0);
+
+ Registry registry = getRegistry();
+ registry.bind("MyService", stub);
+
+ System.err.println("Service ready");
+ }
+
+ protected static void testRmiConfig() {
+ String rmiHost = System.getProperty("java.rmi.server.hostname");
+ if (rmiHost == null || "".equals(rmiHost.trim())) {
+ System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
+ }
+ }
+
+ protected static Registry getRegistry() throws RemoteException {
+ Registry result;
+ try {
+ result = LocateRegistry.getRegistry(PORT);
+ result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
+ } catch (ConnectException ce) {
+ System.err.println("Registry not found, creating a new one");
+ result = LocateRegistry.createRegistry(PORT);
+ }
+ return result;
+ }
+
+ @Override
+ public String testExchange(String whoIsCalling, Integer intValue) throws RemoteException {
+ System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
+ return String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
+ }
+
+}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-11 13:05:58 UTC (rev 456)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -1,6 +1,7 @@
package org.nuiton.sandbox.rmi;
-import java.io.Serializable;
+import org.nuiton.sandbox.business.ServiceInterface;
+
import java.rmi.Remote;
import java.rmi.RemoteException;
Copied: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java (from rev 456, testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java)
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java (rev 0)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/ClientExporter.java 2011-01-12 09:12:32 UTC (rev 457)
@@ -0,0 +1,28 @@
+package org.nuiton.sandbox.rmi;
+
+import org.nuiton.sandbox.business.ServiceInterface;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RemoteObjectInvocationHandler;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ClientExporter {
+
+ private static final int PORT = 12345;
+ public static void main(String[] args) throws Throwable {
+ Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
+ RemoteMethodExecutor stub = (RemoteMethodExecutor)registry.lookup("toto");
+
+ Object result = stub.execute("testExchange", new Class<?>[]{String.class, Integer.class}, new Object[] {System.getProperty("user.name"), 123});
+ System.out.println(result);
+ }
+
+}
1
0
r456 - in testStandaloneRmi/src: main/java/org/nuiton/sandbox/rmi test/java/org/nuiton/sandbox/rmi
by athimel@users.nuiton.org 11 Jan '11
by athimel@users.nuiton.org 11 Jan '11
11 Jan '11
Author: athimel
Date: 2011-01-11 14:05:58 +0100 (Tue, 11 Jan 2011)
New Revision: 456
Url: http://nuiton.org/repositories/revision/sandbox/456
Log:
Valid RMI export test without rmic and without external rmiregistry
Modified:
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java 2011-01-11 10:52:23 UTC (rev 455)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java 2011-01-11 13:05:58 UTC (rev 456)
@@ -1,8 +1,11 @@
package org.nuiton.sandbox.rmi;
+import java.rmi.ConnectException;
+import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
/**
* @author Arnaud Thimel <thimel(a)codelutin.com>
@@ -16,29 +19,40 @@
public static void main(String[] args) throws Exception {
+ testRmiConfig();
+
ServiceImpl impl = new ServiceImpl();
+ Remote stub = UnicastRemoteObject.exportObject(impl, 0);
Registry registry = getRegistry();
- registry.bind("MyService", impl);
+ registry.bind("MyService", stub);
System.err.println("Service ready");
- Thread.sleep(60000);
}
- protected static Registry registry;
+ protected static void testRmiConfig() {
+ String rmiHost = System.getProperty("java.rmi.server.hostname");
+ if (rmiHost == null || "".equals(rmiHost.trim())) {
+ System.err.println("Warning, server might not have been initialized properly, please specify '-Djava.rmi.server.hostname=<IP-address>'");
+ }
+ }
protected static Registry getRegistry() throws RemoteException {
- if (registry == null) {
+ Registry result;
+ try {
+ result = LocateRegistry.getRegistry(PORT);
+ result.list(); // To test that registry has been created. Exception will be thrown is registry cannot be called
+ } catch (ConnectException ce) {
System.err.println("Registry not found, creating a new one");
- registry = LocateRegistry.createRegistry(PORT);
+ result = LocateRegistry.createRegistry(PORT);
}
- return registry;
+ return result;
}
@Override
- public String testExchange(Integer intValue) throws RemoteException {
- System.err.println("Incoming call with value: " + intValue);
- return String.format("What is this fucking number (%d) ?", intValue);
+ public String testExchange(String whoIsCalling, Integer intValue) throws RemoteException {
+ System.out.println(String.format("Incoming call from %s with value: (%d) - Here I'm (%s)", whoIsCalling, intValue, System.getProperty("java.rmi.server.hostname")));
+ return String.format("Hey %s, what is this fucking number '%d' ?", whoIsCalling, intValue);
}
}
Modified: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-11 10:52:23 UTC (rev 455)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-11 13:05:58 UTC (rev 456)
@@ -7,8 +7,8 @@
/**
* @author Arnaud Thimel <thimel(a)codelutin.com>
*/
-public interface ServiceRMIInterface extends Remote, Serializable {
+public interface ServiceRMIInterface extends Remote {
- public abstract String testExchange(Integer intValue) throws RemoteException;
+ public abstract String testExchange(String whoIsCalling, Integer intValue) throws RemoteException;
}
Modified: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java 2011-01-11 10:52:23 UTC (rev 455)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java 2011-01-11 13:05:58 UTC (rev 456)
@@ -12,8 +12,8 @@
public static void main(String[] args) throws Exception {
Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
ServiceRMIInterface stub = (ServiceRMIInterface) registry.lookup("MyService");
- String response = stub.testExchange(123);
+ String response = stub.testExchange(System.getProperty("user.name"), 123);
System.out.println("response: " + response);
+ }
- }
}
1
0
r455 - in testStandaloneRmi: . src src/main src/main/java src/main/java/org src/main/java/org/nuiton src/main/java/org/nuiton/sandbox src/main/java/org/nuiton/sandbox/business src/main/java/org/nuiton/sandbox/rmi src/test src/test/java src/test/java/org src/test/java/org/nuiton src/test/java/org/nuiton/sandbox src/test/java/org/nuiton/sandbox/rmi
by athimel@users.nuiton.org 11 Jan '11
by athimel@users.nuiton.org 11 Jan '11
11 Jan '11
Author: athimel
Date: 2011-01-11 11:52:23 +0100 (Tue, 11 Jan 2011)
New Revision: 455
Url: http://nuiton.org/repositories/revision/sandbox/455
Log:
Ready for remote test
Added:
testStandaloneRmi/pom.xml
testStandaloneRmi/src/
testStandaloneRmi/src/main/
testStandaloneRmi/src/main/java/
testStandaloneRmi/src/main/java/org/
testStandaloneRmi/src/main/java/org/nuiton/
testStandaloneRmi/src/main/java/org/nuiton/sandbox/
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/
testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
testStandaloneRmi/src/test/
testStandaloneRmi/src/test/java/
testStandaloneRmi/src/test/java/org/
testStandaloneRmi/src/test/java/org/nuiton/
testStandaloneRmi/src/test/java/org/nuiton/sandbox/
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/
testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
Modified:
testStandaloneRmi/
Property changes on: testStandaloneRmi
___________________________________________________________________
Added: svn:ignore
+ *.iml
target
.idea
Added: testStandaloneRmi/pom.xml
===================================================================
--- testStandaloneRmi/pom.xml (rev 0)
+++ testStandaloneRmi/pom.xml 2011-01-11 10:52:23 UTC (rev 455)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.nuiton.sandbox</groupId>
+ <artifactId>sandbox-rmi</artifactId>
+ <version>1.0</version>
+
+
+</project>
\ No newline at end of file
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/business/ServiceInterface.java 2011-01-11 10:52:23 UTC (rev 455)
@@ -0,0 +1,7 @@
+package org.nuiton.sandbox.business;
+
+public interface ServiceInterface {
+
+ public abstract String testExchange(Integer intValue);
+
+}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceImpl.java 2011-01-11 10:52:23 UTC (rev 455)
@@ -0,0 +1,44 @@
+package org.nuiton.sandbox.rmi;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class ServiceImpl implements ServiceRMIInterface {
+
+ private static final int PORT = 12345;
+
+ public ServiceImpl() {
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ ServiceImpl impl = new ServiceImpl();
+
+ Registry registry = getRegistry();
+ registry.bind("MyService", impl);
+
+ System.err.println("Service ready");
+ Thread.sleep(60000);
+ }
+
+ protected static Registry registry;
+
+ protected static Registry getRegistry() throws RemoteException {
+ if (registry == null) {
+ System.err.println("Registry not found, creating a new one");
+ registry = LocateRegistry.createRegistry(PORT);
+ }
+ return registry;
+ }
+
+ @Override
+ public String testExchange(Integer intValue) throws RemoteException {
+ System.err.println("Incoming call with value: " + intValue);
+ return String.format("What is this fucking number (%d) ?", intValue);
+ }
+
+}
Added: testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java
===================================================================
--- testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java (rev 0)
+++ testStandaloneRmi/src/main/java/org/nuiton/sandbox/rmi/ServiceRMIInterface.java 2011-01-11 10:52:23 UTC (rev 455)
@@ -0,0 +1,14 @@
+package org.nuiton.sandbox.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public interface ServiceRMIInterface extends Remote, Serializable {
+
+ public abstract String testExchange(Integer intValue) throws RemoteException;
+
+}
Added: testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java
===================================================================
--- testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java (rev 0)
+++ testStandaloneRmi/src/test/java/org/nuiton/sandbox/rmi/Client.java 2011-01-11 10:52:23 UTC (rev 455)
@@ -0,0 +1,19 @@
+package org.nuiton.sandbox.rmi;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class Client {
+
+ private static final int PORT = 12345;
+ public static void main(String[] args) throws Exception {
+ Registry registry = LocateRegistry.getRegistry("10.1.1.85", PORT);
+ ServiceRMIInterface stub = (ServiceRMIInterface) registry.lookup("MyService");
+ String response = stub.testExchange(123);
+ System.out.println("response: " + response);
+
+ }
+}
1
0
Author: athimel
Date: 2011-01-11 11:04:35 +0100 (Tue, 11 Jan 2011)
New Revision: 454
Url: http://nuiton.org/repositories/revision/sandbox/454
Log:
Test for a standalone RMI (create folder)
Added:
testStandaloneRmi/
1
0
r453 - in orion-import-export/src: main/java/fr/orion/io test/java/fr/orion/io
by tchemit@users.nuiton.org 08 Jan '11
by tchemit@users.nuiton.org 08 Jan '11
08 Jan '11
Author: tchemit
Date: 2011-01-08 15:53:40 +0100 (Sat, 08 Jan 2011)
New Revision: 453
Url: http://nuiton.org/repositories/revision/sandbox/453
Log:
fix export order : export order is exactly the insert order to use in the import process
Modified:
orion-import-export/src/main/java/fr/orion/io/OrionEntityVisitorXmlWriter.java
orion-import-export/src/test/java/fr/orion/io/OrionXmlExporterTest.java
Modified: orion-import-export/src/main/java/fr/orion/io/OrionEntityVisitorXmlWriter.java
===================================================================
--- orion-import-export/src/main/java/fr/orion/io/OrionEntityVisitorXmlWriter.java 2011-01-08 14:42:14 UTC (rev 452)
+++ orion-import-export/src/main/java/fr/orion/io/OrionEntityVisitorXmlWriter.java 2011-01-08 14:53:40 UTC (rev 453)
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Stack;
@@ -134,7 +135,8 @@
prefix = prefix0;
- // on ajoute au modele toutes les entites qu'il utilise
+ // on ajoute au modele toutes les entites qu'il utilise dans leur ordre de création
+ Collections.reverse(modelChilds);
for (String s : modelChilds) {
builder.append(s);
}
Modified: orion-import-export/src/test/java/fr/orion/io/OrionXmlExporterTest.java
===================================================================
--- orion-import-export/src/test/java/fr/orion/io/OrionXmlExporterTest.java 2011-01-08 14:42:14 UTC (rev 452)
+++ orion-import-export/src/test/java/fr/orion/io/OrionXmlExporterTest.java 2011-01-08 14:53:40 UTC (rev 453)
@@ -211,13 +211,22 @@
" <id>0</id>\n" +
" <id>1</id>\n" +
" </property>\n" +
- " <QuestionEntity id=\"00\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name00\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <AuditEntity id=\"1\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
+ " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
+ " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <property name=\"question\" type=\"fr.orion.entities.impl.QuestionEntity\">\n" +
+ " <id>10</id>\n" +
+ " <id>11</id>\n" +
+ " </property>\n" +
+ " </AuditEntity>\n" +
+ " <QuestionEntity id=\"11\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <QuestionEntity id=\"01\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name01\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"10\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
" <AuditEntity id=\"0\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name0\"/>\n" +
@@ -231,23 +240,14 @@
" <id>1</id>\n" +
" </property>\n" +
" </AuditEntity>\n" +
- " <QuestionEntity id=\"10\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"01\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name01\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <QuestionEntity id=\"11\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"00\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name00\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <AuditEntity id=\"1\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
- " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
- " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"0\" reverse=\"true\"/>\n" +
- " <property name=\"question\" type=\"fr.orion.entities.impl.QuestionEntity\">\n" +
- " <id>10</id>\n" +
- " <id>11</id>\n" +
- " </property>\n" +
- " </AuditEntity>\n" +
" </ModelEntity>\n" +
" <ModelEntity id=\"1\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
@@ -256,6 +256,11 @@
" <id>10</id>\n" +
" <id>11</id>\n" +
" </property>\n" +
+ " <AuditEntity id=\"11\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
+ " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
+ " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " </AuditEntity>\n" +
" <AuditEntity id=\"10\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
" <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
@@ -265,11 +270,6 @@
" <id>1</id>\n" +
" </property>\n" +
" </AuditEntity>\n" +
- " <AuditEntity id=\"11\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
- " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
- " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"1\" reverse=\"true\"/>\n" +
- " </AuditEntity>\n" +
" </ModelEntity>\n" +
"</export>";
@@ -316,13 +316,22 @@
" <id>0</id>\n" +
" <id>1</id>\n" +
" </property>\n" +
- " <QuestionEntity id=\"00\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name00\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <AuditEntity id=\"1\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
+ " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
+ " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <property name=\"question\" type=\"fr.orion.entities.impl.QuestionEntity\">\n" +
+ " <id>10</id>\n" +
+ " <id>11</id>\n" +
+ " </property>\n" +
+ " </AuditEntity>\n" +
+ " <QuestionEntity id=\"11\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <QuestionEntity id=\"01\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name01\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"10\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
" <AuditEntity id=\"0\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name0\"/>\n" +
@@ -336,23 +345,14 @@
" <id>1</id>\n" +
" </property>\n" +
" </AuditEntity>\n" +
- " <QuestionEntity id=\"10\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"01\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name01\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <QuestionEntity id=\"11\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
- " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " <QuestionEntity id=\"00\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name00\"/>\n" +
+ " <property name=\"audit\" type=\"fr.orion.entities.impl.AuditEntity\" id=\"0\" reverse=\"true\"/>\n" +
" </QuestionEntity>\n" +
- " <AuditEntity id=\"1\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
- " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
- " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"0\" reverse=\"true\"/>\n" +
- " <property name=\"question\" type=\"fr.orion.entities.impl.QuestionEntity\">\n" +
- " <id>10</id>\n" +
- " <id>11</id>\n" +
- " </property>\n" +
- " </AuditEntity>\n" +
" </ModelEntity>\n" +
" <ModelEntity id=\"1\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name1\"/>\n" +
@@ -361,6 +361,11 @@
" <id>10</id>\n" +
" <id>11</id>\n" +
" </property>\n" +
+ " <AuditEntity id=\"11\">\n" +
+ " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
+ " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
+ " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"1\" reverse=\"true\"/>\n" +
+ " </AuditEntity>\n" +
" <AuditEntity id=\"10\">\n" +
" <property name=\"name\" type=\"java.lang.String\" value=\"name10\"/>\n" +
" <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
@@ -370,11 +375,6 @@
" <id>1</id>\n" +
" </property>\n" +
" </AuditEntity>\n" +
- " <AuditEntity id=\"11\">\n" +
- " <property name=\"name\" type=\"java.lang.String\" value=\"name11\"/>\n" +
- " <property name=\"date\" type=\"java.util.Date\" value=\"$date$\"/>\n" +
- " <property name=\"model\" type=\"fr.orion.entities.impl.ModelEntity\" id=\"1\" reverse=\"true\"/>\n" +
- " </AuditEntity>\n" +
" </ModelEntity>\n" +
"</export>";
1
0