diff --git a/pom.xml b/pom.xml index d8a5779..1643705 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,10 @@ com.inteligr8.alfresco aps-public-rest-client - 2.0-SNAPSHOT + 2.0-SNAPSHOT-cxf Alfresco Process Services ReST API Client for Java - An APS Client library for building REST API clients that support either the CXF and Jersey frameworks + An APS Client library for building CXF-based REST API clients https://bitbucket.org/inteligr8/aps-public-rest-client @@ -46,18 +46,19 @@ 5.7.2 5.2.14.RELEASE + 3.4.7 com.inteligr8 common-rest-client - 2.0.1 + 2.0.1-cxf com.inteligr8.alfresco aps-public-rest-api - 2.0.2-${aps.app.tag} + 2.0.3-${aps.app.tag} provided @@ -84,10 +85,43 @@ 2.17.2 test + + + + org.apache.cxf + cxf-rt-rs-client + ${cxf.version} + provided + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-jaxrs-src + add-source + + + src/main/cxf + + + + + add-test-src + add-test-source + + + src/test/cxf + + + + + maven-surefire-plugin 3.0.0-M5 diff --git a/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfConfiguration.java b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfConfiguration.java new file mode 100644 index 0000000..473e6c4 --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfConfiguration.java @@ -0,0 +1,46 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.activiti; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import com.inteligr8.rs.ClientCxfConfiguration; + +/** + * This class provides a POJO & Spring-based implementation of the + * ClientCxfConfiguration interface. You can use it outside of the Spring + * context, but you will need the spring-context and spring-beans libraries in + * your non-Spring application. + * + * @author brian@inteligr8.com + */ +@Configuration +@ComponentScan +public class ApsClientCxfConfiguration extends ApsClientConfiguration implements ClientCxfConfiguration { + + @Value("${process.service.cxf.defaultBusEnabled:true}") + private boolean defaultBusEnabled; + + public boolean isDefaultBusEnabled() { + return this.defaultBusEnabled; + } + + public void setDefaultBusEnabled(boolean defaultBusEnabled) { + this.defaultBusEnabled = defaultBusEnabled; + } + +} diff --git a/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfImpl.java b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfImpl.java new file mode 100644 index 0000000..9d42270 --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsClientCxfImpl.java @@ -0,0 +1,43 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.activiti; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import com.inteligr8.rs.ClientCxfImpl; + +/** + * This class provides a POJO & Spring-based implementation of the Apache + * CXF client. You can use it outside of the Spring context, but you will need + * the spring-context and spring-beans libraries in your non-Spring + * application. + * + * @author brian@inteligr8.com + */ +@Component("aps.client.cxf") +@Lazy +public class ApsClientCxfImpl extends ClientCxfImpl { + + /** + * This constructor is for Spring or POJO use + */ + @Autowired + public ApsClientCxfImpl(ApsClientCxfConfiguration config) { + super(config); + } + +} diff --git a/src/main/cxf/com/inteligr8/alfresco/activiti/ApsPublicRestApiCxfImpl.java b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsPublicRestApiCxfImpl.java new file mode 100644 index 0000000..8c54a2b --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/activiti/ApsPublicRestApiCxfImpl.java @@ -0,0 +1,39 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.activiti; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +/** + * This class provides the Apache CXF client to the JAX-RS API for the APS + * Public ReST API. + * + * @author brian@inteligr8.com + */ +@Component("aps.api.cxf") +@Lazy +public class ApsPublicRestApiCxfImpl extends ApsPublicRestApiImpl implements ApsPublicRestCxfApi { + + /** + * This constructor is for Spring or POJO use + */ + @Autowired + public ApsPublicRestApiCxfImpl(ApsClientCxfImpl client) { + super(client); + } + +} diff --git a/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder b/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder new file mode 100644 index 0000000..018e11f --- /dev/null +++ b/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder @@ -0,0 +1 @@ +org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl \ No newline at end of file diff --git a/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientPojoIT.java b/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientPojoIT.java new file mode 100644 index 0000000..5374095 --- /dev/null +++ b/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientPojoIT.java @@ -0,0 +1,46 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.activiti; + +import org.junit.jupiter.api.BeforeAll; + +import com.inteligr8.rs.ClientConfiguration; + +public class ConnectionCxfClientPojoIT extends ConnectionClientIT { + + private static ApsPublicRestApiImpl api; + + @BeforeAll + public static void initClient() { + ApsClientCxfConfiguration config = new ApsClientCxfConfiguration(); + config.setBaseUrl("http://localhost:8080/activiti-app"); + config.setBasicAuthUsername("admin"); + config.setBasicAuthPassword("admin"); + + api = new ApsPublicRestApiCxfImpl( + new ApsClientCxfImpl(config)); + } + + @Override + public ApsPublicRestApiImpl getApi() { + return api; + } + + @Override + public ClientConfiguration getConfiguration() { + return api.getClient().getConfig(); + } + +} diff --git a/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientSpringIT.java b/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientSpringIT.java new file mode 100644 index 0000000..1e6abb0 --- /dev/null +++ b/src/test/cxf/com/inteligr8/alfresco/activiti/ConnectionCxfClientSpringIT.java @@ -0,0 +1,42 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.activiti; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +import com.inteligr8.rs.ClientConfiguration; + +@TestPropertySource(locations = {"/local-oauth.properties"}) +@SpringJUnitConfig(classes = {ApsClientCxfConfiguration.class, ApsPublicRestApiCxfImpl.class, ApsClientCxfImpl.class}) +public class ConnectionCxfClientSpringIT extends ConnectionClientIT { + + @Autowired + @Qualifier("aps.api.cxf") + private ApsPublicRestApiImpl api; + + @Override + public ApsPublicRestApiImpl getApi() { + return this.api; + } + + @Override + public ClientConfiguration getConfiguration() { + return this.api.getClient().getConfig(); + } + +}