1/*2 * Copyright 2001-2013 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 */17package org.apache.juddi.v3.client.embed;
1819import java.lang.reflect.Method;
2021import org.apache.commons.logging.Log;
22import org.apache.commons.logging.LogFactory;
23import org.apache.juddi.v3.client.ClassUtil;
24/**25 * Implementation of the EmbeddedRegistry to start and stop a inVM jUDDI server.26 * 27 * The implementation is using Reflection to avoid adding a compile time dependency since 28 * it would create a circular dependency as the server already depends on the client.29 * 30 * @author kstam31 *32 */33publicclassJUDDIRegistryimplementsEmbeddedRegistry {
3435private Log logger = LogFactory.getLog(this.getClass());
36publicvoid start() {
37try {
38 Class<?> juddiRegistry = ClassUtil.forName("org.apache.juddi.Registry", JUDDIRegistry.class);
39 Method startMethod = juddiRegistry.getDeclaredMethod("start");
40 startMethod.invoke(juddiRegistry);
41 } catch (Exception e) {
42 logger.error(e.getMessage(),e);
43 }
44 }
4546publicvoid stop() {
47try {
48 Class<?> juddiRegistry = ClassUtil.forName("org.apache.juddi.Registry", JUDDIRegistry.class);
49 Method stopMethod = juddiRegistry.getDeclaredMethod("stop");
50 stopMethod.invoke(juddiRegistry);
51 } catch (Exception e) {
52 logger.error(e.getMessage(),e);
53 }
54 }
5556 }