ARTEMIS-793 Improvements to OSGi Integration
This commit is contained in:
parent
2020dcd290
commit
128a505891
|
@ -96,13 +96,15 @@ public class OsgiBroker {
|
|||
final ActiveMQServer server = (ActiveMQServer) components.get("core");
|
||||
|
||||
String[] requiredProtocols = getRequiredProtocols(server.getConfiguration().getAcceptorConfigurations());
|
||||
ProtocolTrackerCallBack callback = new ProtocolTrackerCallBackImpl(server, context, properties);
|
||||
ServerTrackerCallBack callback = new ServerTrackerCallBackImpl(server, context, properties);
|
||||
|
||||
StoreConfiguration storeConfiguration = server.getConfiguration().getStoreConfiguration();
|
||||
String dataSourceName = String.class.cast(properties.get("dataSourceName"));
|
||||
if (storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName != null &&
|
||||
|
||||
if (storeConfiguration != null &&
|
||||
storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName != null &&
|
||||
!dataSourceName.isEmpty()) {
|
||||
callback = new ServerTrackerCallBackImpl(server, context, properties);
|
||||
callback.setDataSourceDependency(true);
|
||||
String filter = "(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=" + dataSourceName + "))";
|
||||
DataSourceTracker trackerCust =
|
||||
new DataSourceTracker(name, context, DatabaseStorageConfiguration.class.cast(storeConfiguration),
|
||||
|
@ -207,13 +209,15 @@ public class OsgiBroker {
|
|||
}
|
||||
}
|
||||
|
||||
private class ProtocolTrackerCallBackImpl implements ProtocolTrackerCallBack {
|
||||
private class ServerTrackerCallBackImpl implements ServerTrackerCallBack {
|
||||
|
||||
private volatile boolean dataSourceDependency = false;
|
||||
|
||||
private final ActiveMQServer server;
|
||||
private final BundleContext context;
|
||||
private final Dictionary<String, Object> properties;
|
||||
|
||||
ProtocolTrackerCallBackImpl(ActiveMQServer server, BundleContext context,
|
||||
ServerTrackerCallBackImpl(ActiveMQServer server, BundleContext context,
|
||||
Dictionary<String, Object> properties) {
|
||||
this.server = server;
|
||||
this.context = context;
|
||||
|
@ -242,37 +246,28 @@ public class OsgiBroker {
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
List<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
|
||||
for (ActiveMQComponent component : componentsByStartOrder) {
|
||||
component.start();
|
||||
if (!dataSourceDependency) {
|
||||
List<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
|
||||
for (ActiveMQComponent component : componentsByStartOrder) {
|
||||
component.start();
|
||||
}
|
||||
register(context, properties);
|
||||
}
|
||||
register(context, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return server.isStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private class ServerTrackerCallBackImpl extends ProtocolTrackerCallBackImpl implements ServerTrackerCallBack {
|
||||
|
||||
private volatile boolean dataSourceDependency = true;
|
||||
|
||||
ServerTrackerCallBackImpl(ActiveMQServer server, BundleContext context, Dictionary<String, Object> properties) {
|
||||
super(server, context, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataSourceDependency(boolean dataSourceDependency) {
|
||||
this.dataSourceDependency = dataSourceDependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (!dataSourceDependency) {
|
||||
super.start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,12 +43,12 @@ public class ProtocolTracker implements ServiceTrackerCustomizer<ProtocolManager
|
|||
private String name;
|
||||
private BundleContext context;
|
||||
private Map<String, Boolean> protocols;
|
||||
private ProtocolTrackerCallBack callback;
|
||||
private ServerTrackerCallBack callback;
|
||||
|
||||
public ProtocolTracker(String name,
|
||||
BundleContext context,
|
||||
String[] requiredProtocols,
|
||||
ProtocolTrackerCallBack callback) {
|
||||
ServerTrackerCallBack callback) {
|
||||
this.name = name;
|
||||
this.context = context;
|
||||
this.callback = callback;
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.artemis.osgi;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.Interceptor;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
|
||||
|
||||
public interface ProtocolTrackerCallBack extends ActiveMQComponent {
|
||||
|
||||
void addFactory(ProtocolManagerFactory<Interceptor> pmf);
|
||||
|
||||
void removeFactory(ProtocolManagerFactory<Interceptor> pmf);
|
||||
}
|
|
@ -16,7 +16,16 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.osgi;
|
||||
|
||||
public interface ServerTrackerCallBack extends ProtocolTrackerCallBack {
|
||||
import org.apache.activemq.artemis.api.core.Interceptor;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
|
||||
|
||||
public interface ServerTrackerCallBack extends ActiveMQComponent {
|
||||
|
||||
void addFactory(ProtocolManagerFactory<Interceptor> pmf);
|
||||
|
||||
void removeFactory(ProtocolManagerFactory<Interceptor> pmf);
|
||||
|
||||
void setDataSourceDependency(boolean dataSourceDependency);
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ProtocolTrackerTest {
|
|||
IMocksControl c = EasyMock.createControl();
|
||||
BundleContext context = c.createMock(BundleContext.class);
|
||||
String[] requiredProtocols = {"a", "b"};
|
||||
ProtocolTrackerCallBack callback = c.createMock(ProtocolTrackerCallBack.class);
|
||||
ServerTrackerCallBack callback = c.createMock(ServerTrackerCallBack.class);
|
||||
|
||||
RefFact protA = new RefFact(c, context, new String[]{"a"});
|
||||
RefFact protB = new RefFact(c, context, new String[]{"b"});
|
||||
|
|
Loading…
Reference in New Issue