initial public commit
This commit is contained in:
@ -0,0 +1,84 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons;
|
||||
|
||||
import ru.entaxy.esb.system.profile.commons.profile_output.ProfileOutput;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class CommonProfile implements Profile {
|
||||
|
||||
protected String systemName = "system";
|
||||
protected ProfileOutput profileOutput;
|
||||
protected InConnectorCollector inConnectorCollector;
|
||||
|
||||
@Override
|
||||
public void send(Object request) {
|
||||
doSend(request);
|
||||
}
|
||||
|
||||
protected abstract void doSend(Object request);
|
||||
|
||||
@Override
|
||||
public String getSystemName() {
|
||||
return systemName;
|
||||
}
|
||||
|
||||
public void setSystemName(String systemName) {
|
||||
this.systemName = systemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileOutput getProfileOutput() {
|
||||
return profileOutput;
|
||||
}
|
||||
|
||||
public void setProfileOutput(ProfileOutput profileOutput) {
|
||||
this.profileOutput = profileOutput;
|
||||
}
|
||||
|
||||
public InConnectorCollector getInConnectorCollector() {
|
||||
return inConnectorCollector;
|
||||
}
|
||||
|
||||
public void setInConnectorCollector(InConnectorCollector inConnectorCollector) {
|
||||
this.inConnectorCollector = inConnectorCollector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CommonProfile that = (CommonProfile) o;
|
||||
return Objects.equals(systemName, that.systemName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(systemName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommonProfile{" +
|
||||
"systemName='" + systemName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Header;
|
||||
import ru.entaxy.esb.system.common.exception.ConnectorNotFound;
|
||||
import ru.entaxy.esb.system.common.osgi.impl.CommonNamedReferenceListener;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.Connector;
|
||||
|
||||
public class ConnectorRegistry extends CommonNamedReferenceListener<Connector> {
|
||||
|
||||
public String getParam(String systemName, String paramName) {
|
||||
Connector connector = getReference(systemName);
|
||||
if (connector != null) {
|
||||
return connector.getParam(paramName);
|
||||
} else {
|
||||
throw new ConnectorNotFound("Connector for " + systemName + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
public void send(@Header("X-SystemName") String systemName, Exchange exchange) {
|
||||
Connector connector = getReference(systemName);
|
||||
if (connector != null) {
|
||||
connector.send(exchange);
|
||||
} else {
|
||||
throw new ConnectorNotFound("Connector for " + systemName + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getObjectName(Connector Connector) {
|
||||
return Connector.getSystemName();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons;
|
||||
|
||||
import ru.entaxy.esb.system.common.osgi.impl.CommonNamedReferenceListener;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.in.InConnector;
|
||||
|
||||
public class InConnectorCollector extends CommonNamedReferenceListener<InConnector> {
|
||||
|
||||
@Override
|
||||
protected String getObjectName(InConnector inConnector) {
|
||||
return inConnector == null ? null : inConnector.getEndpointName();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons;
|
||||
|
||||
import ru.entaxy.esb.system.profile.commons.profile_output.ProfileOutput;
|
||||
|
||||
public interface Profile {
|
||||
|
||||
ProfileOutput getProfileOutput();
|
||||
|
||||
String getSystemName();
|
||||
|
||||
InConnectorCollector getInConnectorCollector();
|
||||
|
||||
void send(Object request);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors;
|
||||
|
||||
import ru.entaxy.esb.system.profile.commons.Profile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommonConnector implements Connector {
|
||||
protected String endpointName;
|
||||
protected Profile profile;
|
||||
protected String systemName;
|
||||
protected Map<String, String> params;
|
||||
|
||||
public void setEndpointName(String endpointName) {
|
||||
this.endpointName = endpointName;
|
||||
}
|
||||
|
||||
public void setProfile(Profile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public void setSystemName(String systemName) {
|
||||
this.systemName = systemName;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEndpointName() {
|
||||
return endpointName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSystemName() {
|
||||
return systemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParam(String paramName) {
|
||||
return params.get(paramName);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import ru.entaxy.esb.system.profile.commons.Profile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Connector {
|
||||
|
||||
String getEndpointName();
|
||||
|
||||
String getEndpointType();
|
||||
|
||||
Profile getProfile();
|
||||
|
||||
String getSystemName();
|
||||
|
||||
Map<String, String> getParams();
|
||||
|
||||
String getParam(String paramName);
|
||||
|
||||
void send(Exchange exchange);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors.in;
|
||||
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.Connector;
|
||||
|
||||
public interface InConnector extends Connector {
|
||||
|
||||
String endpointType = "in";
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors.in;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.CommonConnector;
|
||||
|
||||
public class QueueInConnectorImpl extends CommonConnector implements InConnector {
|
||||
|
||||
@Override
|
||||
public String getEndpointType() {
|
||||
return endpointType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Exchange exchange) {
|
||||
ProducerTemplate template = exchange.getContext().createProducerTemplate();
|
||||
template.send("direct-vm:" + endpointName + "-" + endpointType + "-connector-" + systemName +
|
||||
"?block=true&timeout=60000", exchange);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors.out;
|
||||
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.Connector;
|
||||
|
||||
public interface OutConnector extends Connector {
|
||||
|
||||
String endpointType = "out";
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.connectors.out;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.CommonConnector;
|
||||
|
||||
public class QueueOutConnectorImpl extends CommonConnector implements OutConnector {
|
||||
|
||||
@Override
|
||||
public String getEndpointType() {
|
||||
return endpointType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Exchange exchange) {
|
||||
ProducerTemplate template = exchange.getContext().createProducerTemplate();
|
||||
template.send("direct-vm:" + endpointName + "-" +
|
||||
endpointType + "-connector-" + systemName + "?block=true&timeout=60000", exchange);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.profile_output;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Header;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.out.OutConnector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProfileOutput {
|
||||
OutConnector getOutConnector(String systemName);
|
||||
|
||||
void send(Exchange exchange);
|
||||
|
||||
void sendTo(@Header("EndpointName") String endpointName, Exchange exchange);
|
||||
|
||||
public List<String> getReferenceNames();
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* profile-commons
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.profile.commons.profile_output;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Header;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import ru.entaxy.esb.system.common.exception.ConnectorNotFound;
|
||||
import ru.entaxy.esb.system.common.osgi.impl.CommonNamedReferenceListener;
|
||||
import ru.entaxy.esb.system.profile.commons.connectors.out.OutConnector;
|
||||
|
||||
public class ProfileOutputImpl extends CommonNamedReferenceListener<OutConnector> implements ProfileOutput {
|
||||
|
||||
protected String systemName;
|
||||
|
||||
public void setSystemName(String systemName) {
|
||||
this.systemName = systemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutConnector getOutConnector(String endpointName) {
|
||||
if (endpointName == null || registeredReferences.get(endpointName) == null) {
|
||||
for (OutConnector outConnector : registeredReferences.values()) {
|
||||
return outConnector;
|
||||
}
|
||||
}
|
||||
return registeredReferences.get(endpointName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Exchange exchange) {
|
||||
ProducerTemplate template = exchange.getContext().createProducerTemplate();
|
||||
template.send("direct-vm:profile-" + systemName + "-enter-point?block=true&timeout=60000", exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTo(@Header("ENTAXY_EndpointName") String endpointName, Exchange exchange) {
|
||||
try {
|
||||
getOutConnector(endpointName).send(exchange);
|
||||
} catch (NullPointerException ex) {
|
||||
throw new ConnectorNotFound("Out connector for " + systemName + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getObjectName(OutConnector outConnector) {
|
||||
return outConnector == null ? null : outConnector.getEndpointName();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
###
|
||||
# ~~~~~~licensing~~~~~~
|
||||
# profile-commons
|
||||
# ==========
|
||||
# Copyright (C) 2020 - 2021 EmDev LLC
|
||||
# ==========
|
||||
# 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.
|
||||
# ~~~~~~/licensing~~~~~~
|
||||
###
|
||||
appender.file.type=File
|
||||
appender.file.name=file
|
||||
appender.file.fileName=target/camel-test.log
|
||||
appender.file.layout.type=PatternLayout
|
||||
appender.file.layout.pattern=%d %-5p %c{1} - %m %n
|
||||
appender.out.type=Console
|
||||
appender.out.name=out
|
||||
appender.out.layout.type=PatternLayout
|
||||
appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
|
||||
rootLogger.level=INFO
|
||||
rootLogger.appenderRef.out.ref=out
|
Reference in New Issue
Block a user