http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-multicast/src/test/java/org/apache/openejb/server/discovery/MulticastPulseAgentTest.java ---------------------------------------------------------------------- diff --git a/server/openejb-multicast/src/test/java/org/apache/openejb/server/discovery/MulticastPulseAgentTest.java b/server/openejb-multicast/src/test/java/org/apache/openejb/server/discovery/MulticastPulseAgentTest.java index 223a768..92147ed 100644 --- a/server/openejb-multicast/src/test/java/org/apache/openejb/server/discovery/MulticastPulseAgentTest.java +++ b/server/openejb-multicast/src/test/java/org/apache/openejb/server/discovery/MulticastPulseAgentTest.java @@ -1,513 +1,513 @@ -/** - * 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.openejb.server.discovery; - -import org.apache.openejb.server.DiscoveryListener; -import org.apache.openejb.util.NetworkUtil; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import sun.net.util.IPAddressUtil; - -import java.net.DatagramPacket; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.MulticastSocket; -import java.net.SocketAddress; -import java.net.URI; -import java.net.UnknownHostException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.TreeSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.ReentrantLock; -import java.util.logging.Logger; - -@SuppressWarnings("UseOfSystemOutOrSystemErr") -public class MulticastPulseAgentTest { - - private static final Set<String> schemes = new HashSet<String>(Arrays.asList("ejbd", "ejbds", "http")); - private static ExecutorService executor; - private static final Charset utf8 = Charset.forName("UTF-8"); - private static final String forGroup = "*"; - private static final String host = "239.255.3.2"; - private static final int port = NetworkUtil.getNextAvailablePort(); - private static MulticastPulseAgent agent; - - @BeforeClass - public static void beforeClass() throws Exception { - - executor = Executors.newFixedThreadPool(10); - - final Properties p = new Properties(); - p.setProperty("bind", host); - p.setProperty("port", "" + port); - - agent = new MulticastPulseAgent(); - agent.init(p); - agent.setDiscoveryListener(new MyDiscoveryListener("MulticastPulseAgentTest")); - agent.registerService(new URI("ejb:ejbd://[::]:4201")); - agent.registerService(new URI("ejb:ejbd://0.0.0.0:4201")); - agent.registerService(new URI("ejb:http://127.0.0.1:4201")); - agent.registerService(new URI("ejb:https://0.0.0.1:4201")); - agent.start(); - - System.out.println(); - } - - @AfterClass - public static void afterClass() throws Exception { - agent.stop(); - executor.shutdownNow(); - } - - /** - * Most of this code is identical to org.apache.openejb.client.MulticastPulseClient#discoverURIs - * <p/> - * The MulticastPulseClient class is not shared or available here so the test has to emulate it. - * - * @throws Exception On error - */ - @Test - public void test() throws Exception { - if ("true".equals(System.getProperty("skipMulticastTests"))) { - Logger.getLogger(this.getClass().getName()).warning("Skipping MulticastTest " + this.getClass().getName()); - return; - } - - final InetAddress ia; - - try { - ia = InetAddress.getByName(host); - } catch (final UnknownHostException e) { - throw new Exception(host + " is not a valid address", e); - } - - if (null == ia || !ia.isMulticastAddress()) { - throw new Exception(host + " is not a valid multicast address"); - } - - //Returns at least one socket per valid network interface - final MulticastSocket[] clientSockets = MulticastPulseAgent.getSockets(host, port); - - //No point going on if we don't have sockets... - if (clientSockets.length < 1) { - System.out.println("Cannnot perform multipulse test without a valid interface"); - return; - } - - final byte[] bytes = (MulticastPulseAgent.CLIENT + forGroup).getBytes(utf8); - final DatagramPacket request = new DatagramPacket(bytes, bytes.length, new InetSocketAddress(ia, port)); - final AtomicBoolean running = new AtomicBoolean(true); - final Timer timer = new Timer(true); - - final Set<URI> set = new TreeSet<URI>(new Comparator<URI>() { - @Override - public int compare(final URI uri1, final URI uri2) { - - //Ignore server hostname - URI u1 = URI.create(uri1.getSchemeSpecificPart()); - URI u2 = URI.create(uri2.getSchemeSpecificPart()); - - //Ignore scheme (ejb,ejbs,etc.) - u1 = URI.create(u1.getSchemeSpecificPart()); - u2 = URI.create(u2.getSchemeSpecificPart()); - - //Compare URI hosts - int i = compare(u1.getHost(), u2.getHost()); - if (i != 0) { - i = uri1.compareTo(uri2); - } - - return i; - } - - private int compare(final String h1, final String h2) { - - //Sort by hostname, IPv4, IPv6 - - try { - if (IPAddressUtil.isIPv4LiteralAddress(h1)) { - if (IPAddressUtil.isIPv6LiteralAddress(h2.replace("[", "").replace("]", ""))) { - return -1; - } - } else if (IPAddressUtil.isIPv6LiteralAddress(h1.replace("[", "").replace("]", ""))) { - if (IPAddressUtil.isIPv4LiteralAddress(h2)) { - return 1; - } - } else if (0 != h1.compareTo(h2)) { - return -1; - } - } catch (final Throwable e) { - //Ignore - } - - return h1.compareTo(h2); - } - }); - - final ReentrantLock setLock = new ReentrantLock(); - - //Start threads that listen for multicast packets on our channel. - //These need to start 'before' we pulse a request. - final ArrayList<Future> futures = new ArrayList<Future>(); - final CountDownLatch latch = new CountDownLatch(clientSockets.length); - - for (final MulticastSocket socket : clientSockets) { - - futures.add(executor.submit(new Runnable() { - @Override - public void run() { - - String name = "Unknown interface"; - try { - name = socket.getNetworkInterface().getDisplayName(); - } catch (final Throwable e) { - //Ignore - } - System.out.println("Entered MulticastPulse client thread on: " + name); - - final DatagramPacket response = new DatagramPacket(new byte[2048], 2048); - - latch.countDown(); - - while (running.get()) { - try { - - socket.receive(response); - - final SocketAddress sa = response.getSocketAddress(); - - if ((sa instanceof InetSocketAddress)) { - - int len = response.getLength(); - if (len > 2048) { - len = 2048; - } - - String s = new String(response.getData(), 0, len); - - if (s.startsWith(MulticastPulseAgent.SERVER)) { - - s = (s.replace(MulticastPulseAgent.SERVER, "")); - final String group = s.substring(0, s.indexOf(':')); - s = s.substring(group.length() + 1); - - if (!"*".equals(forGroup) && !forGroup.equals(group)) { - continue; - } - - final String services = s.substring(0, s.lastIndexOf('|')); - s = s.substring(services.length() + 1); - - final String[] serviceList = services.split("\\|"); - final String[] hosts = s.split(","); - - System.out.println(String.format("\n" + name + " received Server pulse:\n\tGroup: %1$s\n\tServices: %2$s\n\tServer: %3$s\n", - group, - services, - s)); - - for (final String svc : serviceList) { - - if (MulticastPulseAgent.EMPTY.equals(svc)) { - continue; - } - - final URI serviceUri; - try { - serviceUri = URI.create(svc); - } catch (final Throwable e) { - continue; - } - - if (schemes.contains(serviceUri.getScheme())) { - - //Just because multicast was received on this host is does not mean the service is on the same - //We can however use this to identify an individual machine and group - final String serverHost = ((InetSocketAddress) response.getSocketAddress()).getAddress().getHostAddress(); - - final String serviceHost = serviceUri.getHost(); - if (MulticastPulseAgent.isLocalAddress(serviceHost, false)) { - if (!MulticastPulseAgent.isLocalAddress(serverHost, false)) { - //A local service is only available to a local client - continue; - } - } - - final String fullsvc = ("mp-" + serverHost + ":" + group + ":" + svc); - - setLock.lock(); - - try { - if (fullsvc.contains("0.0.0.0")) { - for (final String h : hosts) { - if (!h.replace("[", "").startsWith("2001:0:")) { //Filter Teredo - set.add(URI.create(fullsvc.replace("0.0.0.0", ipFormat(h)))); - } - } - } else if (fullsvc.contains("[::]")) { - for (final String h : hosts) { - if (!h.replace("[", "").startsWith("2001:0:")) { //Filter Teredo - set.add(URI.create(fullsvc.replace("[::]", ipFormat(h)))); - } - } - } else { - //Just add as is - set.add(URI.create(fullsvc)); - } - } catch (final Throwable e) { - //Ignore - } finally { - setLock.unlock(); - } - } else { - System.out.println("Reject service: " + serviceUri.toASCIIString() + " - Not looking for scheme: " + serviceUri.getScheme()); - } - } - } - } - - } catch (final Throwable e) { - //Ignore - } - } - - System.out.println("Exit MulticastPulse client thread on: " + name); - System.out.flush(); - } - })); - } - - //Allow slow thread starts - System.out.println("Wait for threads to start"); - int timeout = 5000; - try { - - //Give threads a generous amount of time to start - if (latch.await(15, TimeUnit.SECONDS)) { - System.out.println("Threads have started"); - - //Pulse the server - It is thread safe to use same sockets as send/receive synchronization is only on the packet - for (final MulticastSocket socket : clientSockets) { - try { - socket.send(request); - } catch (final Throwable e) { - //Ignore - } - } - } else { - timeout = 1; - System.out.println("Giving up on threads"); - } - - } catch (final InterruptedException e) { - timeout = 1; - } - - //Kill the threads after timeout - timer.schedule(new TimerTask() { - @Override - public void run() { - - running.set(false); - - for (final Future future : futures) { - try { - future.cancel(true); - } catch (final Throwable e) { - //Ignore - } - } - - for (final MulticastSocket socket : clientSockets) { - - try { - socket.leaveGroup(ia); - } catch (final Throwable e) { - //Ignore - } - try { - socket.close(); - } catch (final Throwable e) { - //Ignore - } - } - } - }, timeout); - - //Wait for threads to complete - for (final Future future : futures) { - try { - future.get(); - } catch (final Throwable e) { - //Ignore - } - } - - System.out.println(); - System.out.flush(); - - final ArrayList<String> list = new ArrayList<String>(); - - final TreeSet<URI> uris = new TreeSet<URI>(set); - for (final URI uri : uris) { - final String astr = uri.toASCIIString(); - System.out.println("MultiPulse discovered: " + astr); - - if (list.contains(astr)) { - System.out.println("Duplicate uri: " + uri); - } - - org.junit.Assert.assertTrue(!list.contains(astr)); - list.add(astr); - } - - System.out.println("Multipulse complete"); - - //If timeout == 1 assume either a cancel or the test took too long (Will not fail) - org.junit.Assert.assertTrue(timeout == 1 || set.size() > 0); - } - - @Test - public void testBroadcastBadUri() throws Exception { - if ("true".equals(System.getProperty("skipMulticastTests"))) { - Logger.getLogger(this.getClass().getName()).warning("Skipping MulticastTest " + this.getClass().getName()); - return; - } - - final DiscoveryListener original = agent.getDiscoveryListener(); - - final CountDownLatch latch = new CountDownLatch(1); - - final DiscoveryListener listener = new DiscoveryListener() { - @Override - public void serviceAdded(final URI service) { - latch.countDown(); - System.out.println("added = " + service); - } - - @Override - public void serviceRemoved(final URI service) { - latch.countDown(); - System.out.println("removed = " + service); - } - }; - - agent.setDiscoveryListener(listener); - - final String[] hosts = agent.getHosts().split(","); - final String host = hosts[hosts.length - 1]; - - boolean removed = agent.removeFromIgnore(host); - org.junit.Assert.assertTrue("Host is already ignored", !removed); - - final Future<?> future = executor.submit(new Runnable() { - @Override - public void run() { - try { - final InetAddress ia = getAddress(MulticastPulseAgentTest.host); - - final byte[] bytes = (MulticastPulseAgent.CLIENT + forGroup + MulticastPulseAgent.BADURI + host).getBytes(Charset.forName("UTF-8")); - final DatagramPacket request = new DatagramPacket(bytes, bytes.length, new InetSocketAddress(ia, port)); - - final MulticastSocket[] multicastSockets = MulticastPulseAgent.getSockets(MulticastPulseAgentTest.host, port); - - for (int i = 0; i < 5; i++) { - for (final MulticastSocket socket : multicastSockets) { - - try { - socket.send(request); - Thread.sleep(100); - } catch (final Exception e) { - System.out.println("Failed to broadcast bad URI on: " + socket.getInterface().getHostAddress()); - e.printStackTrace(); - } - } - } - } catch (final Exception e) { - System.out.println("Failed to broadcast bad URI"); - e.printStackTrace(); - } - } - }); - - final boolean await = latch.await(20, TimeUnit.SECONDS); - removed = agent.removeFromIgnore(host); - - agent.setDiscoveryListener(original); - - org.junit.Assert.assertTrue("Failed to remove host", removed); - org.junit.Assert.assertTrue("Failed to unlatch", await); - } - - private String ipFormat(final String h) throws UnknownHostException { - - final InetAddress ia = InetAddress.getByName(h); - if (ia instanceof Inet6Address) { - return "[" + ia.getHostAddress() + "]"; - } else { - return h; - } - } - - private static InetAddress getAddress(final String host) throws Exception { - final InetAddress ia; - try { - ia = InetAddress.getByName(host); - } catch (final UnknownHostException e) { - throw new Exception(host + " is not a valid address", e); - } - - if (null == ia || !ia.isMulticastAddress()) { - throw new Exception(host + " is not a valid multicast address"); - } - return ia; - } - - private static class MyDiscoveryListener implements DiscoveryListener { - - private final String id; - - public MyDiscoveryListener(final String id) { - this.id = id; - } - - @Override - public void serviceAdded(final URI service) { - System.out.println(id + ": add : " + service.toString()); - } - - @Override - public void serviceRemoved(final URI service) { - System.out.println(id + ": remove : " + service.toString()); - } - } -} +/** + * 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.openejb.server.discovery; + +import org.apache.openejb.server.DiscoveryListener; +import org.apache.openejb.util.NetworkUtil; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import sun.net.util.IPAddressUtil; + +import java.net.DatagramPacket; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.MulticastSocket; +import java.net.SocketAddress; +import java.net.URI; +import java.net.UnknownHostException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.Logger; + +@SuppressWarnings("UseOfSystemOutOrSystemErr") +public class MulticastPulseAgentTest { + + private static final Set<String> schemes = new HashSet<String>(Arrays.asList("ejbd", "ejbds", "http")); + private static ExecutorService executor; + private static final Charset utf8 = Charset.forName("UTF-8"); + private static final String forGroup = "*"; + private static final String host = "239.255.3.2"; + private static final int port = NetworkUtil.getNextAvailablePort(); + private static MulticastPulseAgent agent; + + @BeforeClass + public static void beforeClass() throws Exception { + + executor = Executors.newFixedThreadPool(10); + + final Properties p = new Properties(); + p.setProperty("bind", host); + p.setProperty("port", "" + port); + + agent = new MulticastPulseAgent(); + agent.init(p); + agent.setDiscoveryListener(new MyDiscoveryListener("MulticastPulseAgentTest")); + agent.registerService(new URI("ejb:ejbd://[::]:4201")); + agent.registerService(new URI("ejb:ejbd://0.0.0.0:4201")); + agent.registerService(new URI("ejb:http://127.0.0.1:4201")); + agent.registerService(new URI("ejb:https://0.0.0.1:4201")); + agent.start(); + + System.out.println(); + } + + @AfterClass + public static void afterClass() throws Exception { + agent.stop(); + executor.shutdownNow(); + } + + /** + * Most of this code is identical to org.apache.openejb.client.MulticastPulseClient#discoverURIs + * <p/> + * The MulticastPulseClient class is not shared or available here so the test has to emulate it. + * + * @throws Exception On error + */ + @Test + public void test() throws Exception { + if ("true".equals(System.getProperty("skipMulticastTests"))) { + Logger.getLogger(this.getClass().getName()).warning("Skipping MulticastTest " + this.getClass().getName()); + return; + } + + final InetAddress ia; + + try { + ia = InetAddress.getByName(host); + } catch (final UnknownHostException e) { + throw new Exception(host + " is not a valid address", e); + } + + if (null == ia || !ia.isMulticastAddress()) { + throw new Exception(host + " is not a valid multicast address"); + } + + //Returns at least one socket per valid network interface + final MulticastSocket[] clientSockets = MulticastPulseAgent.getSockets(host, port); + + //No point going on if we don't have sockets... + if (clientSockets.length < 1) { + System.out.println("Cannnot perform multipulse test without a valid interface"); + return; + } + + final byte[] bytes = (MulticastPulseAgent.CLIENT + forGroup).getBytes(utf8); + final DatagramPacket request = new DatagramPacket(bytes, bytes.length, new InetSocketAddress(ia, port)); + final AtomicBoolean running = new AtomicBoolean(true); + final Timer timer = new Timer(true); + + final Set<URI> set = new TreeSet<URI>(new Comparator<URI>() { + @Override + public int compare(final URI uri1, final URI uri2) { + + //Ignore server hostname + URI u1 = URI.create(uri1.getSchemeSpecificPart()); + URI u2 = URI.create(uri2.getSchemeSpecificPart()); + + //Ignore scheme (ejb,ejbs,etc.) + u1 = URI.create(u1.getSchemeSpecificPart()); + u2 = URI.create(u2.getSchemeSpecificPart()); + + //Compare URI hosts + int i = compare(u1.getHost(), u2.getHost()); + if (i != 0) { + i = uri1.compareTo(uri2); + } + + return i; + } + + private int compare(final String h1, final String h2) { + + //Sort by hostname, IPv4, IPv6 + + try { + if (IPAddressUtil.isIPv4LiteralAddress(h1)) { + if (IPAddressUtil.isIPv6LiteralAddress(h2.replace("[", "").replace("]", ""))) { + return -1; + } + } else if (IPAddressUtil.isIPv6LiteralAddress(h1.replace("[", "").replace("]", ""))) { + if (IPAddressUtil.isIPv4LiteralAddress(h2)) { + return 1; + } + } else if (0 != h1.compareTo(h2)) { + return -1; + } + } catch (final Throwable e) { + //Ignore + } + + return h1.compareTo(h2); + } + }); + + final ReentrantLock setLock = new ReentrantLock(); + + //Start threads that listen for multicast packets on our channel. + //These need to start 'before' we pulse a request. + final ArrayList<Future> futures = new ArrayList<Future>(); + final CountDownLatch latch = new CountDownLatch(clientSockets.length); + + for (final MulticastSocket socket : clientSockets) { + + futures.add(executor.submit(new Runnable() { + @Override + public void run() { + + String name = "Unknown interface"; + try { + name = socket.getNetworkInterface().getDisplayName(); + } catch (final Throwable e) { + //Ignore + } + System.out.println("Entered MulticastPulse client thread on: " + name); + + final DatagramPacket response = new DatagramPacket(new byte[2048], 2048); + + latch.countDown(); + + while (running.get()) { + try { + + socket.receive(response); + + final SocketAddress sa = response.getSocketAddress(); + + if ((sa instanceof InetSocketAddress)) { + + int len = response.getLength(); + if (len > 2048) { + len = 2048; + } + + String s = new String(response.getData(), 0, len); + + if (s.startsWith(MulticastPulseAgent.SERVER)) { + + s = (s.replace(MulticastPulseAgent.SERVER, "")); + final String group = s.substring(0, s.indexOf(':')); + s = s.substring(group.length() + 1); + + if (!"*".equals(forGroup) && !forGroup.equals(group)) { + continue; + } + + final String services = s.substring(0, s.lastIndexOf('|')); + s = s.substring(services.length() + 1); + + final String[] serviceList = services.split("\\|"); + final String[] hosts = s.split(","); + + System.out.println(String.format("\n" + name + " received Server pulse:\n\tGroup: %1$s\n\tServices: %2$s\n\tServer: %3$s\n", + group, + services, + s)); + + for (final String svc : serviceList) { + + if (MulticastPulseAgent.EMPTY.equals(svc)) { + continue; + } + + final URI serviceUri; + try { + serviceUri = URI.create(svc); + } catch (final Throwable e) { + continue; + } + + if (schemes.contains(serviceUri.getScheme())) { + + //Just because multicast was received on this host is does not mean the service is on the same + //We can however use this to identify an individual machine and group + final String serverHost = ((InetSocketAddress) response.getSocketAddress()).getAddress().getHostAddress(); + + final String serviceHost = serviceUri.getHost(); + if (MulticastPulseAgent.isLocalAddress(serviceHost, false)) { + if (!MulticastPulseAgent.isLocalAddress(serverHost, false)) { + //A local service is only available to a local client + continue; + } + } + + final String fullsvc = ("mp-" + serverHost + ":" + group + ":" + svc); + + setLock.lock(); + + try { + if (fullsvc.contains("0.0.0.0")) { + for (final String h : hosts) { + if (!h.replace("[", "").startsWith("2001:0:")) { //Filter Teredo + set.add(URI.create(fullsvc.replace("0.0.0.0", ipFormat(h)))); + } + } + } else if (fullsvc.contains("[::]")) { + for (final String h : hosts) { + if (!h.replace("[", "").startsWith("2001:0:")) { //Filter Teredo + set.add(URI.create(fullsvc.replace("[::]", ipFormat(h)))); + } + } + } else { + //Just add as is + set.add(URI.create(fullsvc)); + } + } catch (final Throwable e) { + //Ignore + } finally { + setLock.unlock(); + } + } else { + System.out.println("Reject service: " + serviceUri.toASCIIString() + " - Not looking for scheme: " + serviceUri.getScheme()); + } + } + } + } + + } catch (final Throwable e) { + //Ignore + } + } + + System.out.println("Exit MulticastPulse client thread on: " + name); + System.out.flush(); + } + })); + } + + //Allow slow thread starts + System.out.println("Wait for threads to start"); + int timeout = 5000; + try { + + //Give threads a generous amount of time to start + if (latch.await(15, TimeUnit.SECONDS)) { + System.out.println("Threads have started"); + + //Pulse the server - It is thread safe to use same sockets as send/receive synchronization is only on the packet + for (final MulticastSocket socket : clientSockets) { + try { + socket.send(request); + } catch (final Throwable e) { + //Ignore + } + } + } else { + timeout = 1; + System.out.println("Giving up on threads"); + } + + } catch (final InterruptedException e) { + timeout = 1; + } + + //Kill the threads after timeout + timer.schedule(new TimerTask() { + @Override + public void run() { + + running.set(false); + + for (final Future future : futures) { + try { + future.cancel(true); + } catch (final Throwable e) { + //Ignore + } + } + + for (final MulticastSocket socket : clientSockets) { + + try { + socket.leaveGroup(ia); + } catch (final Throwable e) { + //Ignore + } + try { + socket.close(); + } catch (final Throwable e) { + //Ignore + } + } + } + }, timeout); + + //Wait for threads to complete + for (final Future future : futures) { + try { + future.get(); + } catch (final Throwable e) { + //Ignore + } + } + + System.out.println(); + System.out.flush(); + + final ArrayList<String> list = new ArrayList<String>(); + + final TreeSet<URI> uris = new TreeSet<URI>(set); + for (final URI uri : uris) { + final String astr = uri.toASCIIString(); + System.out.println("MultiPulse discovered: " + astr); + + if (list.contains(astr)) { + System.out.println("Duplicate uri: " + uri); + } + + org.junit.Assert.assertTrue(!list.contains(astr)); + list.add(astr); + } + + System.out.println("Multipulse complete"); + + //If timeout == 1 assume either a cancel or the test took too long (Will not fail) + org.junit.Assert.assertTrue(timeout == 1 || set.size() > 0); + } + + @Test + public void testBroadcastBadUri() throws Exception { + if ("true".equals(System.getProperty("skipMulticastTests"))) { + Logger.getLogger(this.getClass().getName()).warning("Skipping MulticastTest " + this.getClass().getName()); + return; + } + + final DiscoveryListener original = agent.getDiscoveryListener(); + + final CountDownLatch latch = new CountDownLatch(1); + + final DiscoveryListener listener = new DiscoveryListener() { + @Override + public void serviceAdded(final URI service) { + latch.countDown(); + System.out.println("added = " + service); + } + + @Override + public void serviceRemoved(final URI service) { + latch.countDown(); + System.out.println("removed = " + service); + } + }; + + agent.setDiscoveryListener(listener); + + final String[] hosts = agent.getHosts().split(","); + final String host = hosts[hosts.length - 1]; + + boolean removed = agent.removeFromIgnore(host); + org.junit.Assert.assertTrue("Host is already ignored", !removed); + + final Future<?> future = executor.submit(new Runnable() { + @Override + public void run() { + try { + final InetAddress ia = getAddress(MulticastPulseAgentTest.host); + + final byte[] bytes = (MulticastPulseAgent.CLIENT + forGroup + MulticastPulseAgent.BADURI + host).getBytes(Charset.forName("UTF-8")); + final DatagramPacket request = new DatagramPacket(bytes, bytes.length, new InetSocketAddress(ia, port)); + + final MulticastSocket[] multicastSockets = MulticastPulseAgent.getSockets(MulticastPulseAgentTest.host, port); + + for (int i = 0; i < 5; i++) { + for (final MulticastSocket socket : multicastSockets) { + + try { + socket.send(request); + Thread.sleep(100); + } catch (final Exception e) { + System.out.println("Failed to broadcast bad URI on: " + socket.getInterface().getHostAddress()); + e.printStackTrace(); + } + } + } + } catch (final Exception e) { + System.out.println("Failed to broadcast bad URI"); + e.printStackTrace(); + } + } + }); + + final boolean await = latch.await(20, TimeUnit.SECONDS); + removed = agent.removeFromIgnore(host); + + agent.setDiscoveryListener(original); + + org.junit.Assert.assertTrue("Failed to remove host", removed); + org.junit.Assert.assertTrue("Failed to unlatch", await); + } + + private String ipFormat(final String h) throws UnknownHostException { + + final InetAddress ia = InetAddress.getByName(h); + if (ia instanceof Inet6Address) { + return "[" + ia.getHostAddress() + "]"; + } else { + return h; + } + } + + private static InetAddress getAddress(final String host) throws Exception { + final InetAddress ia; + try { + ia = InetAddress.getByName(host); + } catch (final UnknownHostException e) { + throw new Exception(host + " is not a valid address", e); + } + + if (null == ia || !ia.isMulticastAddress()) { + throw new Exception(host + " is not a valid multicast address"); + } + return ia; + } + + private static class MyDiscoveryListener implements DiscoveryListener { + + private final String id; + + public MyDiscoveryListener(final String id) { + this.id = id; + } + + @Override + public void serviceAdded(final URI service) { + System.out.println(id + ": add : " + service.toString()); + } + + @Override + public void serviceRemoved(final URI service) { + System.out.println(id + ": remove : " + service.toString()); + } + } +}
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/EJBRestServiceInfo.java ---------------------------------------------------------------------- diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/EJBRestServiceInfo.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/EJBRestServiceInfo.java index b8cc1d3..1d68961 100644 --- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/EJBRestServiceInfo.java +++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/EJBRestServiceInfo.java @@ -1,33 +1,33 @@ -/* - * 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.openejb.server.rest; - -import org.apache.openejb.BeanContext; - -public class EJBRestServiceInfo { - public String path; - public BeanContext context; - - public EJBRestServiceInfo(final String path, final BeanContext context) { - if (context == null) { - throw new OpenEJBRestRuntimeException("can't find context"); - } - - this.path = path; - this.context = context; - } -} +/* + * 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.openejb.server.rest; + +import org.apache.openejb.BeanContext; + +public class EJBRestServiceInfo { + public String path; + public BeanContext context; + + public EJBRestServiceInfo(final String path, final BeanContext context) { + if (context == null) { + throw new OpenEJBRestRuntimeException("can't find context"); + } + + this.path = path; + this.context = context; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/InternalApplication.java ---------------------------------------------------------------------- diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/InternalApplication.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/InternalApplication.java index 2035805..cb36fda 100644 --- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/InternalApplication.java +++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/InternalApplication.java @@ -1,45 +1,45 @@ -/* - * 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.openejb.server.rest; - -import javax.ws.rs.core.Application; -import java.util.HashSet; -import java.util.Set; - -public class InternalApplication extends Application { - private final Set<Class<?>> classes = new HashSet<Class<?>>(); - private final Set<Object> singletons = new HashSet<Object>(); - private final Application original; - - public InternalApplication(final Application original) { - this.original = original; - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } - - @Override - public Set<Object> getSingletons() { - return singletons; - } - - public Application getOriginal() { - return original; - } -} +/* + * 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.openejb.server.rest; + +import javax.ws.rs.core.Application; +import java.util.HashSet; +import java.util.Set; + +public class InternalApplication extends Application { + private final Set<Class<?>> classes = new HashSet<Class<?>>(); + private final Set<Object> singletons = new HashSet<Object>(); + private final Application original; + + public InternalApplication(final Application original) { + this.original = original; + } + + @Override + public Set<Class<?>> getClasses() { + return classes; + } + + @Override + public Set<Object> getSingletons() { + return singletons; + } + + public Application getOriginal() { + return original; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-server/src/main/resources/META-INF/openejb-server.xml ---------------------------------------------------------------------- diff --git a/server/openejb-server/src/main/resources/META-INF/openejb-server.xml b/server/openejb-server/src/main/resources/META-INF/openejb-server.xml index 42cd306..05473d9 100644 --- a/server/openejb-server/src/main/resources/META-INF/openejb-server.xml +++ b/server/openejb-server/src/main/resources/META-INF/openejb-server.xml @@ -1,36 +1,36 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> - -<!-- $Rev$ $Date$ --> - -<beans xmlns:s="http://tomee.apache.org/schemas/server" xmlns:c="http://tomee.apache.org/schemas/core" - xmlns:l="http://tomee.apache.org/schemas/loader"> - <s:server id="server" init-method="init"> - <property name="serviceManager" ref="serviceManager" /> - <property name="propertiesService" ref="propertiesService" /> - </s:server> - <c:propertiesService id="propertiesService" /> - <bean id="serviceManager" class="org.apache.openejb.server.ServiceManager" factory-method="getManager" /> - <!-- - - FIXME: The only singleton class with lots of static code - really hard to get it XBean-ized properly - - - <l:system factory-method="get" init-method="init" /> - --> -</beans> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> + +<!-- $Rev$ $Date$ --> + +<beans xmlns:s="http://tomee.apache.org/schemas/server" xmlns:c="http://tomee.apache.org/schemas/core" + xmlns:l="http://tomee.apache.org/schemas/loader"> + <s:server id="server" init-method="init"> + <property name="serviceManager" ref="serviceManager" /> + <property name="propertiesService" ref="propertiesService" /> + </s:server> + <c:propertiesService id="propertiesService" /> + <bean id="serviceManager" class="org.apache.openejb.server.ServiceManager" factory-method="getManager" /> + <!-- + - FIXME: The only singleton class with lots of static code - really hard to get it XBean-ized properly + - + <l:system factory-method="get" init-method="init" /> + --> +</beans> http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-server/src/main/resources/META-INF/org.apache.openejb.cli/stop.help ---------------------------------------------------------------------- diff --git a/server/openejb-server/src/main/resources/META-INF/org.apache.openejb.cli/stop.help b/server/openejb-server/src/main/resources/META-INF/org.apache.openejb.cli/stop.help index 9632aa8..ce00fe0 100644 --- a/server/openejb-server/src/main/resources/META-INF/org.apache.openejb.cli/stop.help +++ b/server/openejb-server/src/main/resources/META-INF/org.apache.openejb.cli/stop.help @@ -1,15 +1,15 @@ -Usage: openejb stop [options] - -Stops the OpenEJB Server running on host 127.0.0.1 and port 4201 - -OPTIONS - -h host Stops the server at the specified host address - Default host is 127.0.0.1 - -p port Stops the server running on the specified port. - Default port is 4201. - -OpenEJB -- EJB Container System and EJB Server. -For OpenEJB updates and additional information, visit -http://tomee.apache.org - +Usage: openejb stop [options] + +Stops the OpenEJB Server running on host 127.0.0.1 and port 4201 + +OPTIONS + -h host Stops the server at the specified host address + Default host is 127.0.0.1 + -p port Stops the server running on the specified port. + Default port is 4201. + +OpenEJB -- EJB Container System and EJB Server. +For OpenEJB updates and additional information, visit +http://tomee.apache.org + Bug Reports to <[email protected]> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/src/main/style/checkstyle.xml ---------------------------------------------------------------------- diff --git a/src/main/style/checkstyle.xml b/src/main/style/checkstyle.xml index 4cc9921..a1524f1 100644 --- a/src/main/style/checkstyle.xml +++ b/src/main/style/checkstyle.xml @@ -1,165 +1,165 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!DOCTYPE module PUBLIC - "-//Puppy Crawl//DTD Check Configuration 1.2//EN" - "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> -<module name="Checker"> - <!-- - If you set the basedir property below, then all reported file - names will be relative to the specified directory. See - http://checkstyle.sourceforge.net/5.x/config.html#Checker - - <property name="basedir" value="${basedir}"/> - --> - - <!-- Checks that property files contain the same keys. --> - <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> - <!--<module name="Translation"/>--> - - <!--<module name="FileLength"/>--> - - <!-- Following interprets the header file as regular expressions. --> - <!-- <module name="RegexpHeader"/> --> - - <module name="SuppressWarningsFilter" /> - - <module name="FileTabCharacter"> - <property name="eachLine" value="true"/> - </module> - - <!--<module name="RegexpSingleline">--> - <!--<!– \s matches whitespace character, $ matches end of line. –>--> - <!--<property name="format" value="\s+$"/>--> - <!--<property name="message" value="Line has trailing spaces."/>--> - <!--</module>--> - - <!-- Checks for Headers --> - <!-- See http://checkstyle.sf.net/config_header.html --> - <!--<module name="Header">--> - <!--<property name="headerFile" value="${checkstyle.header.file}"/>--> - <!--<property name="fileExtensions" value="java"/>--> - <!--</module>--> - - <module name="TreeWalker"> - <module name="SuppressWarningsHolder" /> - - <property name="cacheFile" value="${checkstyle.cache.file}"/> - - <!-- Checks for Javadoc comments. --> - <!-- See http://checkstyle.sf.net/config_javadoc.html --> - <!--<module name="JavadocMethod"/>--> - <!--<module name="JavadocType"/>--> - <!--<module name="JavadocVariable"/>--> - <!--<module name="JavadocStyle"/>--> - - - <!-- Checks for Naming Conventions. --> - <!-- See http://checkstyle.sf.net/config_naming.html --> - <!--<module name="ConstantName"/>--> - <module name="LocalFinalVariableName"/> - <module name="LocalVariableName"/> - <module name="MemberName"/> - <!--<module name="MethodName"/>--> - <module name="PackageName"/> - <module name="ParameterName"/> - <!--<module name="StaticVariableName"/>--> - <!--<module name="TypeName"/>--> - - - <!-- Checks for imports --> - <!-- See http://checkstyle.sf.net/config_import.html --> - <module name="IllegalImport"/> - <!-- defaults to sun.* packages --> - <module name="RedundantImport"/> - <module name="UnusedImports"> - <property name="processJavadoc" value="true" /> - </module> - - - <!-- Checks for Size Violations. --> - <!-- See http://checkstyle.sf.net/config_sizes.html --> - <!--<module name="LineLength">--> - <!--<property name="max" value="120"/>--> - <!--</module>--> - <!--<module name="MethodLength"/>--> - <!--<module name="ParameterNumber"/>--> - - - <!-- Checks for whitespace --> - <!-- See http://checkstyle.sf.net/config_whitespace.html --> - <!--<module name="EmptyForIteratorPad"/>--> - <!--<module name="MethodParamPad"/>--> - <!--<module name="NoWhitespaceAfter"/>--> - <!--<module name="NoWhitespaceBefore"/>--> - <!--<module name="OperatorWrap"/>--> - <!--<module name="ParenPad"/>--> - <!--<module name="TypecastParenPad"/>--> - <!--<module name="WhitespaceAfter"/>--> - - <!-- Modifier Checks --> - <!-- See http://checkstyle.sf.net/config_modifiers.html --> - <module name="ModifierOrder"/> - <module name="RedundantModifier"/> - - - <!-- Checks for blocks. You know, those {}'s --> - <!-- See http://checkstyle.sf.net/config_blocks.html --> - <!--<module name="AvoidNestedBlocks"/>--> - <!--<module name="LeftCurly"/>--> - <module name="NeedBraces"/> - <!--<module name="RightCurly"/>--> - - - <!-- Checks for common coding problems --> - <!-- See http://checkstyle.sf.net/config_coding.html --> - <!--<module name="EmptyStatement"/>--> - <!--<module name="EqualsHashCode"/>--> - <!--<module name="HiddenField">--> - <!--<property name="ignoreSetter" value="true"/>--> - <!--</module>--> - <module name="IllegalInstantiation"/> - <!--<module name="InnerAssignment"/>--> - <!--<module name="MagicNumber">--> - <!--<property name="ignoreHashCodeMethod" value="true"/>--> - <!--</module>--> - <!--<module name="MissingSwitchDefault"/>--> - <!--<module name="RedundantThrows"/>--> - <module name="SimplifyBooleanExpression"/> - <module name="SimplifyBooleanReturn"/> - - <!-- Checks for class design --> - <!-- See http://checkstyle.sf.net/config_design.html --> - <module name="FinalClass"/> - <!--<module name="HideUtilityClassConstructor"/>--> - <!--<module name="InterfaceIsType"/>--> - <!--<module name="VisibilityModifier">--> - <!--<property name="packageAllowed" value="true"/>--> - <!--<property name="protectedAllowed" value="true"/>--> - <!--</module>--> - - <!-- Miscellaneous other checks. --> - <!-- See http://checkstyle.sf.net/config_misc.html --> - <module name="ArrayTypeStyle"/> - <!--<module name="TodoComment"/>--> - <!--<module name="UpperEll"/>--> - - </module> - -</module> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.2//EN" + "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> +<module name="Checker"> + <!-- + If you set the basedir property below, then all reported file + names will be relative to the specified directory. See + http://checkstyle.sourceforge.net/5.x/config.html#Checker + + <property name="basedir" value="${basedir}"/> + --> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <!--<module name="Translation"/>--> + + <!--<module name="FileLength"/>--> + + <!-- Following interprets the header file as regular expressions. --> + <!-- <module name="RegexpHeader"/> --> + + <module name="SuppressWarningsFilter" /> + + <module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module> + + <!--<module name="RegexpSingleline">--> + <!--<!– \s matches whitespace character, $ matches end of line. –>--> + <!--<property name="format" value="\s+$"/>--> + <!--<property name="message" value="Line has trailing spaces."/>--> + <!--</module>--> + + <!-- Checks for Headers --> + <!-- See http://checkstyle.sf.net/config_header.html --> + <!--<module name="Header">--> + <!--<property name="headerFile" value="${checkstyle.header.file}"/>--> + <!--<property name="fileExtensions" value="java"/>--> + <!--</module>--> + + <module name="TreeWalker"> + <module name="SuppressWarningsHolder" /> + + <property name="cacheFile" value="${checkstyle.cache.file}"/> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <!--<module name="JavadocMethod"/>--> + <!--<module name="JavadocType"/>--> + <!--<module name="JavadocVariable"/>--> + <!--<module name="JavadocStyle"/>--> + + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <!--<module name="ConstantName"/>--> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <!--<module name="MethodName"/>--> + <module name="PackageName"/> + <module name="ParameterName"/> + <!--<module name="StaticVariableName"/>--> + <!--<module name="TypeName"/>--> + + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="IllegalImport"/> + <!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"> + <property name="processJavadoc" value="true" /> + </module> + + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <!--<module name="LineLength">--> + <!--<property name="max" value="120"/>--> + <!--</module>--> + <!--<module name="MethodLength"/>--> + <!--<module name="ParameterNumber"/>--> + + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <!--<module name="EmptyForIteratorPad"/>--> + <!--<module name="MethodParamPad"/>--> + <!--<module name="NoWhitespaceAfter"/>--> + <!--<module name="NoWhitespaceBefore"/>--> + <!--<module name="OperatorWrap"/>--> + <!--<module name="ParenPad"/>--> + <!--<module name="TypecastParenPad"/>--> + <!--<module name="WhitespaceAfter"/>--> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <module name="ModifierOrder"/> + <module name="RedundantModifier"/> + + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <!--<module name="AvoidNestedBlocks"/>--> + <!--<module name="LeftCurly"/>--> + <module name="NeedBraces"/> + <!--<module name="RightCurly"/>--> + + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!--<module name="EmptyStatement"/>--> + <!--<module name="EqualsHashCode"/>--> + <!--<module name="HiddenField">--> + <!--<property name="ignoreSetter" value="true"/>--> + <!--</module>--> + <module name="IllegalInstantiation"/> + <!--<module name="InnerAssignment"/>--> + <!--<module name="MagicNumber">--> + <!--<property name="ignoreHashCodeMethod" value="true"/>--> + <!--</module>--> + <!--<module name="MissingSwitchDefault"/>--> + <!--<module name="RedundantThrows"/>--> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <module name="FinalClass"/> + <!--<module name="HideUtilityClassConstructor"/>--> + <!--<module name="InterfaceIsType"/>--> + <!--<module name="VisibilityModifier">--> + <!--<property name="packageAllowed" value="true"/>--> + <!--<property name="protectedAllowed" value="true"/>--> + <!--</module>--> + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="ArrayTypeStyle"/> + <!--<module name="TodoComment"/>--> + <!--<module name="UpperEll"/>--> + + </module> + +</module> http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tck/tck-common/src/main/java/org/apache/openejb/tck/util/ServerLocal.java ---------------------------------------------------------------------- diff --git a/tck/tck-common/src/main/java/org/apache/openejb/tck/util/ServerLocal.java b/tck/tck-common/src/main/java/org/apache/openejb/tck/util/ServerLocal.java index 856c429..422b12b 100644 --- a/tck/tck-common/src/main/java/org/apache/openejb/tck/util/ServerLocal.java +++ b/tck/tck-common/src/main/java/org/apache/openejb/tck/util/ServerLocal.java @@ -1,50 +1,50 @@ -/* - * 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.openejb.tck.util; - -import org.apache.tomee.util.QuickServerXmlParser; - -import java.io.File; - -public class ServerLocal { - - private ServerLocal() { - } - - /** - * If the TCK is running against a local server extracted to the target dir - * then the server.xml will have the port defined already. - * - * @param def Default port to use if none is found - * @return The determined port, the value of 'server.http.port' or the provided default - */ - public static int getPort(final int def) { - final String home = System.getProperty("openejb.home", "empty"); - - if (!"empty".equals(home)) { - final File serverXml = new File(home, "conf/server.xml"); - - if (serverXml.exists() && serverXml.isFile()) { - final QuickServerXmlParser parser = QuickServerXmlParser.parse(serverXml); - - return Integer.parseInt(parser.http()); - } - } - - return Integer.getInteger("server.http.port", def); - } -} +/* + * 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.openejb.tck.util; + +import org.apache.tomee.util.QuickServerXmlParser; + +import java.io.File; + +public class ServerLocal { + + private ServerLocal() { + } + + /** + * If the TCK is running against a local server extracted to the target dir + * then the server.xml will have the port defined already. + * + * @param def Default port to use if none is found + * @return The determined port, the value of 'server.http.port' or the provided default + */ + public static int getPort(final int def) { + final String home = System.getProperty("openejb.home", "empty"); + + if (!"empty".equals(home)) { + final File serverXml = new File(home, "conf/server.xml"); + + if (serverXml.exists() && serverXml.isFile()) { + final QuickServerXmlParser parser = QuickServerXmlParser.parse(serverXml); + + return Integer.parseInt(parser.http()); + } + } + + return Integer.getInteger("server.http.port", def); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/apache-tomee/src/main/resources/service.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/service.bat b/tomee/apache-tomee/src/main/resources/service.bat index b061f3f..457b4c0 100644 --- a/tomee/apache-tomee/src/main/resources/service.bat +++ b/tomee/apache-tomee/src/main/resources/service.bat @@ -1,226 +1,226 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -rem The following line can be used to define a specific jre or jdk path -rem set "JAVA_HOME=C:/JDK" - -REM Prefer a local JRE if we find one in the current bin directory -IF EXIST "%~dp0jre" ( - SET "JRE_HOME=%~dp0jre" -) - -REM Prefer a local JDK if we find one in the current bin directory -IF EXIST "%~dp0jdk" ( - SET "JAVA_HOME=%~dp0jdk" -) - -@IF NOT "%ECHO%" == "" ECHO %ECHO% -@IF "%OS%" == "Windows_NT" setlocal - -IF "%OS%" == "Windows_NT" ( - SET "DIRNAME=%~dp0%" -) ELSE ( - SET DIRNAME=.\ -) - -pushd %DIRNAME% - -rem --------------------------------------------------------------------------- -rem NT Service Install/Uninstall script -rem -rem Options -rem install Install the service using TomEE as service name. -rem Service is installed using default settings. -rem remove Remove the service from the System. -rem -rem name (optional) If the second argument is present it is considered -rem to be new service name -rem -rem $Id: service.bat 1000718 2010-09-24 06:00:00Z mturk $ -rem --------------------------------------------------------------------------- - -SET proc=undefined - -IF /i %PROCESSOR_ARCHITECTURE% EQU X86 SET "proc=%~dp0TomEE.x86.exe" -IF /i %PROCESSOR_ARCHITECTURE% EQU AMD64 SET "proc=%~dp0TomEE.amd64.exe" -IF /i %PROCESSOR_ARCHITECTURE% EQU IA64 SET "proc=%~dp0TomEE.ia64.exe" - -IF /i "%proc%" EQU undefined ( - ECHO Failed to determine OS architecture - GOTO end -) - -set "SELF=%~dp0%service.bat" -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%cd%" -if exist "%CATALINA_HOME%\bin\service.bat" goto okHome -rem CD to the upper dir -cd .. -set "CATALINA_HOME=%cd%" -:gotHome -if exist "%CATALINA_HOME%\bin\service.bat" goto okHome -echo The service exe was not found... -echo The CATALINA_HOME environment variable is not defined correctly. -echo This environment variable is needed to run this program -goto end -:okHome -rem Make sure prerequisite environment variables are set -if not "%JAVA_HOME%" == "" goto gotJdkHome -if not "%JRE_HOME%" == "" goto gotJreHome -echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined -echo Service will try to guess them from the registry. -goto okJavaHome -:gotJreHome -if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome -if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome -goto okJavaHome -:gotJdkHome -if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome -if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome -if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome -if not "%JRE_HOME%" == "" goto okJavaHome -set "JRE_HOME=%JAVA_HOME%\jre" -goto okJavaHome -:noJavaHome -echo The JAVA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -echo NB: JAVA_HOME should point to a JDK not a JRE -goto end -:okJavaHome -if not "%CATALINA_BASE%" == "" goto gotBase -set "CATALINA_BASE=%CATALINA_HOME%" -:gotBase - -set "EXECUTABLE=%proc%" - -rem Set default Service name (If you change this then rename also TomEE.exe to the same name) -set SERVICE_NAME=TomEE -set PR_DISPLAYNAME=Apache TomEE - -if "x%1x" == "xx" goto displayUsage -set SERVICE_CMD=%1 -shift -if "x%1x" == "xx" goto checkServiceCmd -:checkUser -if "x%1x" == "x/userx" goto runAsUser -if "x%1x" == "x--userx" goto runAsUser -set SERVICE_NAME=%1 -set PR_DISPLAYNAME=Apache TomEE (%1) -shift -if "x%1x" == "xx" goto checkServiceCmd -goto checkUser -:runAsUser -shift -if "x%1x" == "xx" goto displayUsage -set SERVICE_USER=%1 -shift -runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%" -goto end -:checkServiceCmd -if /i %SERVICE_CMD% == install goto doInstall -if /i %SERVICE_CMD% == remove goto doRemove -if /i %SERVICE_CMD% == uninstall goto doRemove -echo Unknown parameter "%1" -:displayUsage -echo. -echo Usage: service.bat install/remove [service_name] [/user username] -goto end - -:doRemove -rem Remove the service -"%EXECUTABLE%" //DS//%SERVICE_NAME% -if not errorlevel 1 goto removed -echo Failed removing '%SERVICE_NAME%' service -goto end -:removed -echo The service '%SERVICE_NAME%' has been removed -goto end - -:doInstall -rem Install the service -echo Installing the service '%SERVICE_NAME%' ... -echo Using CATALINA_HOME: "%CATALINA_HOME%" -echo Using CATALINA_BASE: "%CATALINA_BASE%" -echo Using JAVA_HOME: "%JAVA_HOME%" -echo Using JRE_HOME: "%JRE_HOME%" - -rem Use the environment variables as an example -rem Each command line option is prefixed with PR_ - -set "PR_DESCRIPTION=Apache TomEE - http://tomee.apache.org/" -set "PR_INSTALL=%EXECUTABLE%" -set "PR_LOGPATH=%CATALINA_BASE%\logs" -set "PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar" -rem Set the server jvm from JAVA_HOME -set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll" -if exist "%PR_JVM%" goto foundJvm -rem Set the client jvm from JAVA_HOME -set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll" -if exist "%PR_JVM%" goto foundJvm -set PR_JVM=auto -:foundJvm -echo Using JVM: "%PR_JVM%" - -"%EXECUTABLE%" //IS//%SERVICE_NAME% ^ - --DisplayName=%SERVICE_NAME% ^ - --StartClass org.apache.catalina.startup.Bootstrap ^ - --StopClass org.apache.catalina.startup.Bootstrap ^ - --StartParams start ^ - --StopParams stop ^ - --Startup auto ^ - --JvmMs=512 ^ - --JvmMx=1024 ^ - --JvmSs=2048 ^ - --StartMode jvm ^ - --StopMode jvm ^ - --LogLevel Info ^ - --LogPrefix TomEE - -echo Installed, will now configure TomEE - -if not errorlevel 1 goto installed -echo Failed installing '%SERVICE_NAME%' service -goto end - -:installed -rem Clear the environment variables. They are not needed any more. -set PR_DISPLAYNAME= -set PR_DESCRIPTION= -set PR_INSTALL= -set PR_LOGPATH= -set PR_CLASSPATH= -set PR_JVM= - -rem Set extra parameters -"%EXECUTABLE%" //US//%SERVICE_NAME% ^ - ++JvmOptions "-javaagent:%CATALINA_HOME%\lib\openejb-javaagent.jar;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" - -rem More extra parameters -set "PR_LOGPATH=%CATALINA_BASE%\logs" -set PR_STDOUTPUT=auto -set PR_STDERROR=auto - -rem before this option was added: "++JvmOptions=-Djava.library.path="%CATALINA_BASE%\bin" ^" -rem the drawback was it was preventing custom native lib to be loaded even if added to Path -"%EXECUTABLE%" //US//%SERVICE_NAME% ^ - ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Djava.awt.headless=true;-XX:+UseParallelGC;-XX:MaxPermSize=256M" - -echo The service '%SERVICE_NAME%' has been installed. - -:end -cd "%CURRENT_DIR%" +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +rem The following line can be used to define a specific jre or jdk path +rem set "JAVA_HOME=C:/JDK" + +REM Prefer a local JRE if we find one in the current bin directory +IF EXIST "%~dp0jre" ( + SET "JRE_HOME=%~dp0jre" +) + +REM Prefer a local JDK if we find one in the current bin directory +IF EXIST "%~dp0jdk" ( + SET "JAVA_HOME=%~dp0jdk" +) + +@IF NOT "%ECHO%" == "" ECHO %ECHO% +@IF "%OS%" == "Windows_NT" setlocal + +IF "%OS%" == "Windows_NT" ( + SET "DIRNAME=%~dp0%" +) ELSE ( + SET DIRNAME=.\ +) + +pushd %DIRNAME% + +rem --------------------------------------------------------------------------- +rem NT Service Install/Uninstall script +rem +rem Options +rem install Install the service using TomEE as service name. +rem Service is installed using default settings. +rem remove Remove the service from the System. +rem +rem name (optional) If the second argument is present it is considered +rem to be new service name +rem +rem $Id: service.bat 1000718 2010-09-24 06:00:00Z mturk $ +rem --------------------------------------------------------------------------- + +SET proc=undefined + +IF /i %PROCESSOR_ARCHITECTURE% EQU X86 SET "proc=%~dp0TomEE.x86.exe" +IF /i %PROCESSOR_ARCHITECTURE% EQU AMD64 SET "proc=%~dp0TomEE.amd64.exe" +IF /i %PROCESSOR_ARCHITECTURE% EQU IA64 SET "proc=%~dp0TomEE.ia64.exe" + +IF /i "%proc%" EQU undefined ( + ECHO Failed to determine OS architecture + GOTO end +) + +set "SELF=%~dp0%service.bat" +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%cd%" +if exist "%CATALINA_HOME%\bin\service.bat" goto okHome +rem CD to the upper dir +cd .. +set "CATALINA_HOME=%cd%" +:gotHome +if exist "%CATALINA_HOME%\bin\service.bat" goto okHome +echo The service exe was not found... +echo The CATALINA_HOME environment variable is not defined correctly. +echo This environment variable is needed to run this program +goto end +:okHome +rem Make sure prerequisite environment variables are set +if not "%JAVA_HOME%" == "" goto gotJdkHome +if not "%JRE_HOME%" == "" goto gotJreHome +echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined +echo Service will try to guess them from the registry. +goto okJavaHome +:gotJreHome +if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome +if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome +goto okJavaHome +:gotJdkHome +if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome +if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome +if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome +if not "%JRE_HOME%" == "" goto okJavaHome +set "JRE_HOME=%JAVA_HOME%\jre" +goto okJavaHome +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +echo NB: JAVA_HOME should point to a JDK not a JRE +goto end +:okJavaHome +if not "%CATALINA_BASE%" == "" goto gotBase +set "CATALINA_BASE=%CATALINA_HOME%" +:gotBase + +set "EXECUTABLE=%proc%" + +rem Set default Service name (If you change this then rename also TomEE.exe to the same name) +set SERVICE_NAME=TomEE +set PR_DISPLAYNAME=Apache TomEE + +if "x%1x" == "xx" goto displayUsage +set SERVICE_CMD=%1 +shift +if "x%1x" == "xx" goto checkServiceCmd +:checkUser +if "x%1x" == "x/userx" goto runAsUser +if "x%1x" == "x--userx" goto runAsUser +set SERVICE_NAME=%1 +set PR_DISPLAYNAME=Apache TomEE (%1) +shift +if "x%1x" == "xx" goto checkServiceCmd +goto checkUser +:runAsUser +shift +if "x%1x" == "xx" goto displayUsage +set SERVICE_USER=%1 +shift +runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%" +goto end +:checkServiceCmd +if /i %SERVICE_CMD% == install goto doInstall +if /i %SERVICE_CMD% == remove goto doRemove +if /i %SERVICE_CMD% == uninstall goto doRemove +echo Unknown parameter "%1" +:displayUsage +echo. +echo Usage: service.bat install/remove [service_name] [/user username] +goto end + +:doRemove +rem Remove the service +"%EXECUTABLE%" //DS//%SERVICE_NAME% +if not errorlevel 1 goto removed +echo Failed removing '%SERVICE_NAME%' service +goto end +:removed +echo The service '%SERVICE_NAME%' has been removed +goto end + +:doInstall +rem Install the service +echo Installing the service '%SERVICE_NAME%' ... +echo Using CATALINA_HOME: "%CATALINA_HOME%" +echo Using CATALINA_BASE: "%CATALINA_BASE%" +echo Using JAVA_HOME: "%JAVA_HOME%" +echo Using JRE_HOME: "%JRE_HOME%" + +rem Use the environment variables as an example +rem Each command line option is prefixed with PR_ + +set "PR_DESCRIPTION=Apache TomEE - http://tomee.apache.org/" +set "PR_INSTALL=%EXECUTABLE%" +set "PR_LOGPATH=%CATALINA_BASE%\logs" +set "PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar" +rem Set the server jvm from JAVA_HOME +set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll" +if exist "%PR_JVM%" goto foundJvm +rem Set the client jvm from JAVA_HOME +set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll" +if exist "%PR_JVM%" goto foundJvm +set PR_JVM=auto +:foundJvm +echo Using JVM: "%PR_JVM%" + +"%EXECUTABLE%" //IS//%SERVICE_NAME% ^ + --DisplayName=%SERVICE_NAME% ^ + --StartClass org.apache.catalina.startup.Bootstrap ^ + --StopClass org.apache.catalina.startup.Bootstrap ^ + --StartParams start ^ + --StopParams stop ^ + --Startup auto ^ + --JvmMs=512 ^ + --JvmMx=1024 ^ + --JvmSs=2048 ^ + --StartMode jvm ^ + --StopMode jvm ^ + --LogLevel Info ^ + --LogPrefix TomEE + +echo Installed, will now configure TomEE + +if not errorlevel 1 goto installed +echo Failed installing '%SERVICE_NAME%' service +goto end + +:installed +rem Clear the environment variables. They are not needed any more. +set PR_DISPLAYNAME= +set PR_DESCRIPTION= +set PR_INSTALL= +set PR_LOGPATH= +set PR_CLASSPATH= +set PR_JVM= + +rem Set extra parameters +"%EXECUTABLE%" //US//%SERVICE_NAME% ^ + ++JvmOptions "-javaagent:%CATALINA_HOME%\lib\openejb-javaagent.jar;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" + +rem More extra parameters +set "PR_LOGPATH=%CATALINA_BASE%\logs" +set PR_STDOUTPUT=auto +set PR_STDERROR=auto + +rem before this option was added: "++JvmOptions=-Djava.library.path="%CATALINA_BASE%\bin" ^" +rem the drawback was it was preventing custom native lib to be loaded even if added to Path +"%EXECUTABLE%" //US//%SERVICE_NAME% ^ + ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Djava.awt.headless=true;-XX:+UseParallelGC;-XX:MaxPermSize=256M" + +echo The service '%SERVICE_NAME%' has been installed. + +:end +cd "%CURRENT_DIR%"
