refactor: remove commented-out code segments
Delete various bits of code that has been forgotten about.
DELETE
gateway/api/rest/src/main/java/io/apiman/gateway/api/rest/IPolicyResource.java
-// package io.apiman.gateway.api.rest;
-//
-// import io.apiman.gateway.engine.beans.IPolicyProbeRequest;
-// import io.apiman.gateway.engine.beans.IPolicyProbeResponse;
-//
-// import javax.annotation.Resource;
-// import javax.ws.rs.Consumes;
-// import javax.ws.rs.GET;
-// import javax.ws.rs.Produces;
-// import javax.ws.rs.container.AsyncResponse;
-// import javax.ws.rs.container.Suspended;
-// import javax.ws.rs.core.MediaType;
-// import javax.ws.rs.core.Request;
-//
-// import io.swagger.annotations.Api;
-// import io.swagger.annotations.ApiImplicitParam;
-// import io.swagger.annotations.ApiImplicitParams;
-// import io.swagger.annotations.ApiOperation;
-// import io.swagger.annotations.ApiResponse;
-// import io.swagger.annotations.ApiResponses;
-//
-// /**
-// * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
-// */
-// @Api(tags = "policy")
-// @Resource(name = "policy", description = "Probe information relating to the state of policies")
-// public interface IPolicyResource {
-//
-// @GET
-// @ApiOperation(value = "Probe the state of a policy")
-// @ApiResponses(
-// @ApiResponse(code = 200, message = "OK", response = IPolicyProbeResponse.class)
-// )
-// @ApiImplicitParams(
-// @ApiImplicitParam(name = "request", dataTypeClass = IPolicyProbeRequest.class)
-// )
-// @Consumes(MediaType.APPLICATION_JSON)
-// @Produces(MediaType.APPLICATION_JSON)
-// void probePolicy(final Request request, @Suspended final AsyncResponse response);
-// }

DELETE
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractMappedPolicyWithProbe.java
-// /*
-// * Copyright 2014 JBoss Inc
-// *
-// * Licensed under the Apache License, Version 2.0 (the "License");
-// * you may not use this file except in compliance with the License.
-// * You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-// */
-// package io.apiman.gateway.engine.policies;
-//
-// import io.apiman.gateway.engine.async.IAsyncResultHandler;
-// import io.apiman.gateway.engine.beans.ApiRequest;
-// import io.apiman.gateway.engine.beans.ApiResponse;
-// import io.apiman.gateway.engine.beans.IPolicyProbeRequest;
-// import io.apiman.gateway.engine.beans.IPolicyProbeResponse;
-// import io.apiman.gateway.engine.beans.PolicyFailure;
-// import io.apiman.gateway.engine.beans.exceptions.ConfigurationParseException;
-// import io.apiman.gateway.engine.policy.IPolicy;
-// import io.apiman.gateway.engine.policy.IPolicyChain;
-// import io.apiman.gateway.engine.policy.IPolicyContext;
-// import io.apiman.gateway.engine.policy.IPolicyFailureChain;
-//
-// import com.fasterxml.jackson.databind.DeserializationFeature;
-// import com.fasterxml.jackson.databind.ObjectMapper;
-// import com.fasterxml.jackson.databind.SerializationFeature;
-// import com.fasterxml.jackson.databind.json.JsonMapper;
-// import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-// import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-// import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
-//
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_JAVA_COMMENTS;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_SINGLE_QUOTES;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_TRAILING_COMMA;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS;
-// import static com.fasterxml.jackson.core.json.JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES;
-//
-// /**
-// * A base class for policy impls that uses Jackson to parse configuration info.
-// *
-// * @author eric.wittmann@redhat.com
-// * @author marc@blackparrotlabs.io
-// * @param <C> the config type
-// * @param <P> the probe request type
-// */
-// public abstract class AbstractMappedPolicyWithProbe<C, P extends IPolicyProbeRequest> implements IPolicy {
-//
-// private static final ObjectMapper mapper = JsonMapper
-// .builder()
-// // (mostly) match the JSON5 spec.
-// .enable(ALLOW_UNQUOTED_FIELD_NAMES)
-// .enable(ALLOW_TRAILING_COMMA)
-// .enable(ALLOW_SINGLE_QUOTES)
-// .enable(ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)
-// .enable(ALLOW_NON_NUMERIC_NUMBERS)
-// .enable(ALLOW_JAVA_COMMENTS)
-// .enable(ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS)
-// .enable(ALLOW_UNESCAPED_CONTROL_CHARS)
-// // Avoid weird floating point timestamps
-// .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
-// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
-// // Enable various Java 8 and library data structures to be serialized
-// .addModule(new JavaTimeModule())
-// .addModule(new ParameterNamesModule())
-// .addModule(new Jdk8Module())
-// .build();
-//
-// /**
-// * Constructor.
-// */
-// public AbstractMappedPolicyWithProbe() {
-// }
-//
-// /**
-// * {@inheritDoc}
-// * <p>
-// * Using Jackson, the configuration is read into the class specified structure by {@link #getConfigurationClass()}.
-// * <p>
-// * Most implementors should not override this method unless they do not want to use Jackson (e.g. using a non-JSON
-// * format).
-// */
-// @Override
-// public C parseConfiguration(String jsonConfiguration) throws ConfigurationParseException {
-// try {
-// return mapper.readerFor(getConfigurationClass()).readValue(jsonConfiguration);
-// } catch (Exception e) {
-// throw new ConfigurationParseException(e);
-// }
-// }
-//
-// /**
-// * The class to use for JSON configuration deserialization
-// *
-// * @return the class
-// */
-// protected abstract Class<C> getConfigurationClass();
-//
-// /**
-// * {@inheritDoc}
-// */
-// @SuppressWarnings("unchecked")
-// @Override
-// public final void apply(ApiRequest request, IPolicyContext context, Object config,
-// IPolicyChain<ApiRequest> chain) {
-// doApply(request, context, (C) config, chain);
-// }
-//
-// /**
-// * Override this method to interact with or observe the request.
-// *
-// * @see #apply(ApiResponse, IPolicyContext, Object, IPolicyChain)
-// * @param request the request
-// * @param chain the ordered policy chain
-// */
-// protected void doApply(ApiRequest request, IPolicyContext context, C config, IPolicyChain<ApiRequest> chain) {
-// chain.doApply(request);
-// }
-//
-// /**
-// * {@inheritDoc}
-// */
-// @SuppressWarnings("unchecked")
-// @Override
-// public final void apply(ApiResponse response, IPolicyContext context, Object config,
-// IPolicyChain<ApiResponse> chain) {
-// doApply(response, context, (C) config, chain);
-// }
-//
-// /**
-// * Apply the policy to the response.
-// * <p>
-// * Override this method to interact with or observe the response.
-// *
-// * @param response the response
-// * @param context the policy context
-// * @param config the configuration (see {@link #getConfigurationClass()})
-// * @param chain the ordered policy chain
-// */
-// protected void doApply(ApiResponse response, IPolicyContext context, C config, IPolicyChain<ApiResponse> chain) {
-// chain.doApply(response);
-// }
-//
-// @SuppressWarnings("unchecked")
-// @Override
-// public void processFailure(PolicyFailure failure, IPolicyContext context, Object config, IPolicyFailureChain chain) {
-// doProcessFailure(failure, context, (C) config, chain);
-// }
-//
-// /**
-// * Override if you wish to modify a failure.
-// *
-// * @see IPolicy#processFailure(PolicyFailure, IPolicyContext, Object, IPolicyFailureChain)
-// */
-// protected void doProcessFailure(PolicyFailure failure, IPolicyContext context, C config, IPolicyFailureChain chain) {
-// chain.doFailure(failure);
-// }
-//
-// /**
-// * Return the class to unmarshall the raw probe request JSON configuration into.
-// * <p>
-// * For compatibility reasons this is not abstract, but all classes who provide probe capabilities should implement it.
-// */
-// protected Class<P> getProbeRequestClass() {
-// return null;
-// }
-//
-// /**
-// * {@inheritDoc}
-// * <p>
-// * This version uses Jackson to parse the probe configuration into the class specified by
-// * {@link #getProbeRequestClass()}, and the policy config specified by {@link #getConfigurationClass()}.
-// * <p>
-// * Most implementors should override the abstract
-// * {@link #doProbe(IPolicyProbeRequest, Object, IPolicyContext, IAsyncResultHandler)} method rather than this one,
-// * unless they are doing something more exotic (e.g. not using JSON).
-// */
-// @Override
-// public void probe(String probeRequestRaw, String policyConfigRaw, IPolicyContext context, IAsyncResultHandler<IPolicyProbeResponse> resultHandler) {
-// try {
-// P probeConfig = mapper.readValue(probeRequestRaw, getProbeRequestClass());
-// C policyConfig = mapper.readValue(policyConfigRaw, getConfigurationClass());
-// doProbe(probeConfig, policyConfig, context, resultHandler);
-// } catch (Exception e) {
-// throw new ConfigurationParseException(e);
-// }
-// }
-//
-// /**
-// * Override this method to provide a state probe for your policy implementation.
-// *
-// * @see IPolicy#probe(String, String, IPolicyContext, IAsyncResultHandler)
-// */
-// protected abstract void doProbe(P probeRequest, C policyConfig, IPolicyContext context, IAsyncResultHandler<IPolicyProbeResponse> resultHandler);
-// }

DELETE
manager/api/core/src/main/java/io/apiman/manager/api/core/ITransactionalOutbox.java
-package io.apiman.manager.api.core;
-
-/**
- * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
- */
-public interface ITransactionalOutbox {
-
-}

DELETE
manager/api/jpa/src/main/resources/WEB-INF/jetty-env.xml
-<!--<New id="tx" class="org.eclipse.jetty.plus.jndi.Transaction">-->
-<!-- <Arg>-->
-<!-- <New class="com.atomikos.icatch.jta.J2eeUserTransaction"/>-->
-<!-- </Arg>-->
-<!--</New>-->
-
-<!--<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">-->
-<!--<Arg></Arg>-->
-<!--<Arg>jdbc/DSTest</Arg>-->
-<!--<Arg>-->
-<!-- <New class="com.atomikos.jdbc.AtomikosDataSourceBean">-->
-<!-- <Set name="minPoolSize">2</Set>-->
-<!-- <Set name="maxPoolSize">50</Set>-->
-<!-- <Set name="xaDataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</Set>-->
-<!-- <Set name="UniqueResourceName">DSTest</Set>-->
-<!-- <Get name="xaProperties">-->
-<!-- <Call name="setProperty">-->
-<!-- <Arg>url</Arg>-->
-<!-- <Arg>jdbc:mysql://localhost:3306/databasename</Arg>-->
-<!-- </Call>-->
-<!-- <Call name="setProperty">-->
-<!-- <Arg>user</Arg>-->
-<!-- <Arg>some_username</Arg>-->
-<!-- </Call>-->
-<!-- <Call name="setProperty">-->
-<!-- <Arg>password</Arg>-->
-<!-- <Arg>some_password</Arg>-->
-<!-- </Call>-->
-<!-- </Get>-->
-<!-- </New>-->
-<!--</Arg>-->
-<!--</New>-->
-

MODIFY
manager/pom.xml
manager/pom.xml
<packaging>pom</packaging>
<name>apiman-manager</name>
-<!-- <dependencies>-->
-<!-- <dependency>-->
-<!-- <groupId>org.slf4j</groupId>-->
-<!-- <artifactId>slf4j-api</artifactId>-->
-<!-- <scope>provided</scope>-->
-<!-- </dependency>-->
-<!-- </dependencies>-->
<modules>
<module>sso</module>
<module>api</module>

MODIFY
manager/test/api/pom.xml
manager/test/api/pom.xml
</exclusion>
</exclusions>
</dependency>
-<!-- <dependency>-->
-<!-- <groupId>org.slf4j</groupId>-->
-<!-- <artifactId>slf4j-api</artifactId>-->
-<!-- </dependency>-->
-<!-- <dependency>-->
-<!-- <artifactId>slf4j-log4j12</artifactId>-->
-<!-- <groupId>org.slf4j</groupId>-->
-<!-- </dependency>-->
-<!-- -->
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>

DELETE
manager/test/api/src/main/java/io/apiman/manager/test/server/JettyTransactionalInterceptor0.java
-// package io.apiman.manager.test.server;
-//
-// import javax.annotation.PostConstruct;
-// import javax.annotation.Priority;
-// import javax.inject.Inject;
-// import javax.interceptor.AroundInvoke;
-// import javax.interceptor.Interceptor;
-// import javax.interceptor.InvocationContext;
-// import javax.persistence.EntityManager;
-// import javax.persistence.PersistenceContext;
-// import javax.transaction.TransactionRolledbackException;
-// import javax.transaction.Transactional;
-//
-// /**
-// * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
-// */
-// @Priority(Interceptor.Priority.LIBRARY_BEFORE-10)
-// @Interceptor
-// @Transactional
-// public class JettyTransactionalInterceptor {
-//
-// @PersistenceContext(unitName = "apiman-manager-api-jpa")
-// @Inject
-// EntityManager em;
-//
-// public JettyTransactionalInterceptor() {
-// }
-//
-// @PostConstruct
-// public void hello() {
-// System.out.println("hello");
-// }
-//
-// @AroundInvoke
-// public Object auditMethod(InvocationContext ctx) throws Exception {
-// if (!em.getTransaction().isActive()) {
-// System.out.println("Beginning TX");
-// em.getTransaction().begin();
-// } else {
-// System.out.println("Committing TX");
-// em.getTransaction().commit();
-// System.out.println("Beginning TX (after commit)");
-// em.getTransaction().begin();
-// }
-//
-// Object result = null;
-// try {
-// result = ctx.proceed();
-// em.getTransaction().commit();
-// System.out.println("Committed TX");
-// } catch (Exception e) {
-// em.getTransaction().rollback();
-// System.out.println("Rolled back TX");
-// //throw new TransactionRolledbackException();
-// throw e;
-// }
-// return result;
-// }
-// }

DELETE
manager/test/api/src/main/java/io/apiman/manager/test/server/JettyTransactionalInterceptor2.java
-// package io.apiman.manager.test.server;
-//
-// import javax.annotation.PostConstruct;
-// import javax.annotation.Priority;
-// import javax.inject.Inject;
-// import javax.interceptor.AroundInvoke;
-// import javax.interceptor.Interceptor;
-// import javax.interceptor.InvocationContext;
-// import javax.persistence.EntityManager;
-// import javax.persistence.PersistenceContext;
-// import javax.transaction.Status;
-// import javax.transaction.SystemException;
-// import javax.transaction.Transaction;
-// import javax.transaction.TransactionManager;
-// import javax.transaction.Transactional;
-//
-// import com.atomikos.icatch.jta.UserTransactionManager;
-//
-// /**
-// *
-// */
-// @Priority(Interceptor.Priority.LIBRARY_BEFORE)
-// @Interceptor
-// @Transactional
-// public class JettyTransactionalInterceptor2 {
-//
-// @PersistenceContext(unitName = "apiman-manager-api-jpa")
-// @Inject
-// EntityManager em;
-//
-// // @Inject
-// // private TransactionManager tm;
-// // @Inject
-// private UserTransactionManager tm = new UserTransactionManager();
-//
-// public JettyTransactionalInterceptor2() {
-//
-// }
-//
-// @PostConstruct
-// public void post() throws SystemException {
-// tm.init();
-// }
-//
-// @AroundInvoke
-// public Object intercept(InvocationContext ic) throws Exception {
-// Transaction tx = tm.getTransaction();
-// if (tx == null) {
-// System.out.println("Invoke in our tx");
-// return invokeInOurTx(ic);
-// } else {
-// System.out.println("Invoke in caller tx");
-// return invokeInCallerTx(ic, tx);
-// }
-// }
-//
-// private Object invokeInOurTx(InvocationContext ic) throws Exception {
-// tm.begin();
-// //em.joinTransaction();
-// System.out.println("Beginning transaction");
-// Transaction tx = tm.getTransaction();
-//
-// try {
-// return ic.proceed();
-// } catch (Exception e) {
-// handleException(ic, e, tx);
-// } finally {
-// endTransaction(tm, tx);
-// }
-// throw new RuntimeException("UNREACHABLE");
-//
-// // if (!tx.get()) {
-// // System.out.println("Beginning TX");
-// // em.getTransaction().begin();
-// // }
-// // Object result = null;
-// // try {
-// // result = ctx.proceed();
-// // } catch (Exception e) {
-// // tx.rollback();
-// // System.out.println("Rolled back TX");
-// // throw e;
-// // } finally {
-// // if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
-// // tm.rollback();
-// // } else {
-// // tm.commit();
-// // }
-// // }
-// // return result;
-// }
-//
-// private void endTransaction(TransactionManager tm, Transaction tx) throws Exception {
-// if (tx != tm.getTransaction()) {
-// throw new RuntimeException("tx on wrong thread");
-// }
-//
-// if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
-// System.out.println("Rolling back");
-// tm.rollback();
-// } else {
-// System.out.println("Committing transaction");
-// System.out.println("tx active? " + em.getTransaction().isActive());
-// em.flush();
-// tm.commit();
-// System.out.println("tx active? " + em.getTransaction().isActive());
-// }
-// }
-//
-// private void handleException(InvocationContext ic, Exception e, Transaction tx) throws Exception {
-// if (e instanceof RuntimeException) {
-// System.out.println("Rollback only set");
-// tx.setRollbackOnly();
-// throw e;
-// }
-//
-// throw e;
-// }
-//
-//
-// private Object invokeInCallerTx(InvocationContext ic, Transaction tx) throws Exception {
-// try {
-// return ic.proceed();
-// } catch (Exception e) {
-// handleException(ic, e, tx);
-// }
-// throw new RuntimeException("UNREACHABLE");
-// }
-// }

DELETE
manager/test/api/src/main/resources/WEB-INF/jetty-env.xml
-<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
-<Configure id="webAppCtx" class="org.eclipse.jetty.webapp.WebAppContext">
- <New id="tx" class="org.eclipse.jetty.plus.jndi.Transaction">
- <Arg>
- <New class="com.atomikos.icatch.jta.UserTransactionManager"/>
- </Arg>
- </New>
-</Configure>

DELETE
manager/ui/war/src/main/java/io/apiman/manager/ui/server/i18n/ExternalMessages.java
-package io.apiman.manager.ui.server.i18n;/**
- *
- *
- * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
- */public class ExternalMessages {
-}

MODIFY
test/common/src/main/java/io/apiman/test/common/json/JsonCompare.java
test/common/src/main/java/io/apiman/test/common/json/JsonCompare.java
@@ -180,13 +180,15 @@ public class JsonCompare {
* @param actualJson
*/
public void assertJson(JsonNode expectedJson, JsonNode actualJson) {
+ String expectedS = null;
+ String actualS = null;
try {
- String expectedS = jacksonParser.writeValueAsString(expectedJson);
- System.out.println("expected:" + expectedS);
- String actualS = jacksonParser.writeValueAsString(actualJson);
- System.out.println("actual:" + actualS);
+ expectedS = jacksonParser.writeValueAsString(expectedJson);
+ actualS = jacksonParser.writeValueAsString(actualJson);
JSONAssert.assertEquals(expectedS, actualS, new WildcardComparator(JSONCompareMode.LENIENT));
} catch (JsonProcessingException | JSONException e1) {
+ System.out.println("Expected: " + expectedS);
+ System.out.println("Actual: " + actualS);
throw new RuntimeException(e1);
}
}

DELETE
tools/apiman.war.dodeploy
tools/apiman.war.dodeploy
refactor: remove commented-out code segments

Delete various bits of code that has been forgotten about.