You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/12/14 18:19:32 UTC
svn commit: r1421989 - in /cxf/dosgi/trunk/distribution/single-bundle/src:
main/java/org/apache/cxf/dosgi/singlebundle/
test/java/org/apache/cxf/dosgi/singlebundle/
Author: dkulp
Date: Fri Dec 14 17:19:30 2012
New Revision: 1421989
URL: http://svn.apache.org/viewvc?rev=1421989&view=rev
Log:
Cleanpu single-bundle
Modified:
cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/SPIActivator.java
cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java
Modified: cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java?rev=1421989&r1=1421988&r2=1421989&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java Fri Dec 14 17:19:30 2012
@@ -1,21 +1,21 @@
-/**
- * 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.
- */
+/**
+ * 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.cxf.dosgi.singlebundle;
import java.io.BufferedReader;
@@ -34,14 +34,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AggregatedActivator implements BundleActivator {
- private static final Logger LOG = LoggerFactory.getLogger(AggregatedActivator.class);
-
static final String HTTP_PORT_PROPERTY = "org.osgi.service.http.port";
static final String HTTPS_PORT_PROPERTY = "org.osgi.service.http.port.secure";
static final String HTTPS_ENABLED_PROPERTY = "org.osgi.service.http.secure.enabled";
static final String ACTIVATOR_RESOURCE = "activators.list";
+ static String defaultHttpPort = "8080";
+
+ private static final Logger LOG = LoggerFactory.getLogger(AggregatedActivator.class);
- static String DEFAULT_HTTP_PORT = "8080";
+
private List<BundleActivator> activators = new ArrayList<BundleActivator>();
@@ -65,9 +66,9 @@ public class AggregatedActivator impleme
}
if (port == null || port.length() == 0) {
- port = tryPortFree(DEFAULT_HTTP_PORT);
+ port = tryPortFree(defaultHttpPort);
if (port == null) {
- LOG.debug("Port {} is not available. ", DEFAULT_HTTP_PORT);
+ LOG.debug("Port {} is not available. ", defaultHttpPort);
port = tryPortFree("0");
}
LOG.info("Setting HttpService port to: " + port);
@@ -76,7 +77,8 @@ public class AggregatedActivator impleme
System.setProperty(prop, port);
} else {
if (tryPortFree(port) == null) {
- LOG.warn("The system is configured to use HttpService port {}. However this port is already in use.", port);
+ LOG.warn("The system is configured to use HttpService port {}. However this port is already in use.",
+ port);
} else {
LOG.info("HttpService using port: {}", port);
}
@@ -88,8 +90,8 @@ public class AggregatedActivator impleme
ServerSocket s = null;
try {
- s = new ServerSocket(p);
- return "" + s.getLocalPort();
+ s = new ServerSocket(p);
+ return "" + s.getLocalPort();
} catch (IOException e) {
return null;
} finally {
@@ -133,11 +135,11 @@ public class AggregatedActivator impleme
void stopEmbeddedActivators(BundleContext ctx) throws Exception {
for (BundleActivator ba : activators) {
- try {
+ try {
ba.stop(ctx);
- } catch (Throwable ex) {
- LOG.warn("BundleActivator {} can not be stopped", ba.getClass().getName());
- }
+ } catch (Throwable ex) {
+ LOG.warn("BundleActivator {} can not be stopped", ba.getClass().getName());
+ }
}
}
Modified: cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/SPIActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/SPIActivator.java?rev=1421989&r1=1421988&r2=1421989&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/SPIActivator.java (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/SPIActivator.java Fri Dec 14 17:19:30 2012
@@ -1,25 +1,24 @@
-/**
- * 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.
- */
+/**
+ * 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.cxf.dosgi.singlebundle;
import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
@@ -36,12 +35,11 @@ import org.osgi.framework.BundleActivato
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+@SuppressWarnings("rawtypes") //smx OsgiLocator mandates poor use of Class instead of Class<?>
public class SPIActivator implements BundleActivator, SynchronousBundleListener {
- private static final Logger LOG = LoggerFactory.getLogger(SPIActivator.class);
- private ConcurrentMap<Long, Map<String, Callable<Class>>> factories = new ConcurrentHashMap<Long, Map<String, Callable<Class>>>();
+ private ConcurrentMap<Long, Map<String, Callable<Class>>> factories
+ = new ConcurrentHashMap<Long, Map<String, Callable<Class>>>();
public synchronized void start(BundleContext bundleContext) throws Exception {
register(bundleContext.getBundle());
@@ -88,7 +86,7 @@ public class SPIActivator implements Bun
factories.put(bundle.getBundleId(), map);
}
map.put(factoryId, new Callable<Class>() {
- public Class call() throws Exception {
+ public Class<?> call() throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));
String factoryClassName = br.readLine();
br.close();
Modified: cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java?rev=1421989&r1=1421988&r2=1421989&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java Fri Dec 14 17:19:30 2012
@@ -1,20 +1,20 @@
-/**
- * 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.
+/**
+ * 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.cxf.dosgi.singlebundle;
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import junit.framework.TestCase;
@@ -31,17 +32,17 @@ import org.easymock.EasyMock;
import org.osgi.framework.BundleContext;
public class AggregatedActivatorTest extends TestCase {
- private HashMap<Object, Object> savedProps;
+ private Map<Object, Object> savedProps;
private String oldDefaultPort;
@Override
protected void setUp() throws Exception {
- oldDefaultPort = AggregatedActivator.DEFAULT_HTTP_PORT;
+ oldDefaultPort = AggregatedActivator.defaultHttpPort;
// Change the default port to one that we know is available
ServerSocket s = new ServerSocket(0);
int availablePort = s.getLocalPort();
s.close();
- AggregatedActivator.DEFAULT_HTTP_PORT = "" + availablePort;
+ AggregatedActivator.defaultHttpPort = "" + availablePort;
savedProps = new HashMap<Object, Object>(System.getProperties());
super.setUp();
@@ -54,7 +55,7 @@ public class AggregatedActivatorTest ext
props.putAll(savedProps);
System.setProperties(props);
- AggregatedActivator.DEFAULT_HTTP_PORT = oldDefaultPort;
+ AggregatedActivator.defaultHttpPort = oldDefaultPort;
}
public void testReadResourcesFile() throws Exception {
@@ -68,8 +69,7 @@ public class AggregatedActivatorTest ext
"org.apache.cxf.dosgi.topologymanager.Activator",
"org.springframework.osgi.extender.internal.activator.ContextLoaderListener"};
- AggregatedActivator aa = new AggregatedActivator();
- assertEquals(Arrays.asList(expected), aa.getActivators());
+ assertEquals(Arrays.asList(expected), AggregatedActivator.getActivators());
}
public void testDefaultHttpServicePort() {
@@ -78,7 +78,7 @@ public class AggregatedActivatorTest ext
assertNull("Precondition failed", System.getProperty(AggregatedActivator.HTTP_PORT_PROPERTY));
new AggregatedActivator().setHttpServicePort(bc);
- assertEquals(AggregatedActivator.DEFAULT_HTTP_PORT, System.getProperty(AggregatedActivator.HTTP_PORT_PROPERTY));
+ assertEquals(AggregatedActivator.defaultHttpPort, System.getProperty(AggregatedActivator.HTTP_PORT_PROPERTY));
}
public void testHttpServicePortFromProperty() {
@@ -87,7 +87,7 @@ public class AggregatedActivatorTest ext
andReturn("1234").anyTimes();
EasyMock.replay(bc);
- HashMap<Object, Object> before = new HashMap<Object, Object>(System.getProperties());
+ Map<Object, Object> before = new HashMap<Object, Object>(System.getProperties());
new AggregatedActivator().setHttpServicePort(bc);
assertEquals("No additional properties should have been set",
before, new HashMap<Object, Object>(System.getProperties()));
@@ -101,7 +101,7 @@ public class AggregatedActivatorTest ext
andReturn("true").anyTimes();
EasyMock.replay(bc);
- HashMap<Object, Object> before = new HashMap<Object, Object>(System.getProperties());
+ Map<Object, Object> before = new HashMap<Object, Object>(System.getProperties());
new AggregatedActivator().setHttpServicePort(bc);
assertEquals("No additional properties should have been set",
before, new HashMap<Object, Object>(System.getProperties()));
@@ -116,7 +116,7 @@ public class AggregatedActivatorTest ext
try {
// now lets block the default port
s = new ServerSocket(Integer.parseInt(
- AggregatedActivator.DEFAULT_HTTP_PORT));
+ AggregatedActivator.defaultHttpPort));
} catch (Exception e) {
// if someone else already has it, thats fine too
}