This project has retired. For details please refer to its Attic page.
JUDDIRegistry xref
View Javadoc
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 at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * 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 and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.client.embed;
18  
19  import java.lang.reflect.Method;
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  import 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 kstam
31   *
32   */
33  public class JUDDIRegistry implements EmbeddedRegistry {
34  
35  	private Log logger = LogFactory.getLog(this.getClass());
36  	public void start() {
37  		try {
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  	}
45  
46  	public void stop() {
47  		try {
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  	}
55  
56  }