01: /*
02: * <copyright>
03: *
04: * Copyright 2002-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.pizza.plugin;
28:
29: import java.io.File;
30: import java.net.URL;
31:
32: import org.cougaar.pizza.Constants;
33: import org.cougaar.servicediscovery.plugin.SimpleSDRegistrationPlugin;
34:
35: import org.cougaar.util.Configuration;
36:
37: /**
38: * Extension of the SimpleSDRegistrationPlugin to use the pizza serviceprofiles.
39: * Registers this agent's services as specified in
40: * the <agent name>-profile.owl file if any in the plugin parameter-named YP agent.
41: * <p>
42: * Remember that this version of the SDRegistration plugin is somewhat simplified
43: * -- fewer error checks for example.
44: *<p>
45: * Note that the only change this extension has to make, is to point the plugin
46: * at the correct directory for the service profiles for this application.
47: * <p>
48: * First plugin argument is the name of the agent hosting the YP that we will register with.
49: *
50: * @property org.cougaar.servicediscovery.plugin.SimpleRegistrationGracePeriod is the
51: * number of minutes after startup, during which we ignore SD registration Warnings,
52: * to allow the YP to start up. After this we complain more loudly. Default is 5 minutes.
53: **/
54: public class SDRegistrationPlugin extends SimpleSDRegistrationPlugin {
55: /**
56: * Get the URL for the service profiles directory for this application.
57: * This is the only method we need to over-ride to customize the base class for the
58: * pizza application.
59: *<p>
60: * Note that we use the method in {@link Constants} to find the directory contains the service profiles.
61: */
62: protected URL getServiceProfileURL() {
63: try {
64: // URLify the data path, to handle C:/... in Windows paths, for example
65: return new URL(Configuration
66: .urlify(Constants.getDataPath())
67: + File.separator
68: + "serviceprofiles"
69: + File.separator);
70: } catch (java.net.MalformedURLException mue) {
71: log
72: .error(
73: "Exception constructing service profile URL",
74: mue);
75: return null;
76: }
77: }
78: }
|