2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.auth.server;
22 import org.onap.aaf.auth.org.OrganizationException;
23 import org.onap.aaf.auth.org.OrganizationFactory;
24 import org.onap.aaf.auth.rserv.RServlet;
25 import org.onap.aaf.cadi.Access;
26 import org.onap.aaf.cadi.register.Registrant;
27 import org.onap.aaf.cadi.register.Registrar;
28 import org.onap.aaf.misc.env.Trans;
29 import org.onap.aaf.misc.rosetta.env.RosettaEnv;
31 public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> implements ServiceStarter {
32 private Registrar<ENV> registrar;
33 private boolean do_register;
34 protected AbsService<ENV,TRANS> service;
37 public AbsServiceStarter(final AbsService<ENV,TRANS> service) {
38 this.service = service;
40 OrganizationFactory.init(service.env);
41 } catch (OrganizationException e) {
42 service.access.log(e, "Missing defined Organzation Plugins");
45 // do_register - this is used for specialty Debug Situations. Developer can create an Instance for a remote system
46 // for Debugging purposes without fear that real clients will start to call your debug instance
47 do_register = !"TRUE".equalsIgnoreCase(access().getProperty("aaf_locate_no_register",null));
48 _propertyAdjustment();
51 public abstract void _start(RServlet<TRANS> rserv) throws Exception;
52 public abstract void _propertyAdjustment();
58 public Access access() {
59 return service.access;
63 public final void start() throws Exception {
65 Runtime.getRuntime().addShutdownHook(new Thread() {
74 public final synchronized void register(final Registrant<ENV> ... registrants) {
77 registrar = new Registrar<ENV>(env(),false);
79 for(Registrant<ENV> r : registrants) {
80 registrar.register(r);
86 public void shutdown() {
88 registrar.close(env());