001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)DeploymentListenerImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * DeploymentListener.java
031: *
032: * SUN PROPRIETARY/CONFIDENTIAL.
033: * This software is the proprietary information of Sun Microsystems, Inc.
034: * Use is subject to license terms.
035: *
036: */package com.sun.jbi.internal.security;
037:
038: import com.sun.jbi.binding.security.Endpoint;
039:
040: import com.sun.jbi.internal.security.config.EndpointSecurityConfig;
041: import com.sun.jbi.internal.security.config.EndptSecConfigReader;
042:
043: import java.util.Vector;
044:
045: /**
046: * No-op implementation of Deployment Listener.
047: *
048: * @author Sun Microsystems, Inc.
049: */
050: public class DeploymentListenerImpl implements
051: com.sun.jbi.binding.security.DeploymentListener,
052: DeploymentNotifier {
053: /** Observers. */
054: private Vector mObservers = null;
055:
056: /** Schema Dir. */
057: private String mSchemaDir;
058:
059: /** The Logger. */
060: private java.util.logging.Logger mLogger;
061:
062: /**
063: * @param schemaDir directory for the deployment schema.
064: */
065: public DeploymentListenerImpl(String schemaDir) {
066: mLogger = java.util.logging.Logger.getLogger(Constants.PACKAGE);
067: mObservers = new Vector();
068: mSchemaDir = schemaDir;
069: }
070:
071: /**
072: * Notification for a new Endpoint Deployment.
073: *
074: * @param endpoint is the Endpoint being deployed.
075: * @throws Exception on errors
076: */
077: public void addDeployment(Endpoint endpoint) throws Exception {
078: try {
079:
080: // -- Create the EndpointSecurityConfig
081: EndptSecConfigReader reader = new EndptSecConfigReader(
082: SecurityService
083: .getStringTranslator(Constants.PACKAGE),
084: mSchemaDir);
085: reader.setValidating(true);
086:
087: EndpointSecurityConfig epSecConfig = new com.sun.jbi.internal.security.config.EndptSecConfig();
088: if (endpoint.getSecurityConfigFileName() != null) {
089: epSecConfig = reader.read(new java.io.File(endpoint
090: .getSecurityConfigFileName()));
091: }
092:
093: // -- notify Observers of event
094: java.util.Iterator itr = mObservers.iterator();
095: while (itr.hasNext()) {
096: DeploymentObserver obs = (DeploymentObserver) itr
097: .next();
098: obs.registerEndpointDeployment(endpoint, epSecConfig);
099: }
100: } catch (Exception ex) {
101: // -- Print a error Message Here
102: mLogger
103: .severe("Error occured in deploying the endpoint to the Security"
104: + " Service, details " + ex.getMessage());
105: ex.printStackTrace();
106: throw ex;
107: }
108:
109: }
110:
111: /**
112: * Notification for removal of an Endpoint Deployment.
113: *
114: * @param endpoint is the Endpoint being undeployed.
115: */
116: public void removeDeployment(Endpoint endpoint) {
117: // -- notify Observers of event
118: java.util.Iterator itr = mObservers.iterator();
119:
120: while (itr.hasNext()) {
121: DeploymentObserver obs = (DeploymentObserver) itr.next();
122: obs.unregisterEndpointDeployment(endpoint);
123: }
124: }
125:
126: /**
127: * @param obs is an observer of deployments.
128: */
129: public void addDeploymentObserver(DeploymentObserver obs) {
130: mObservers.add(obs);
131: }
132:
133: /**
134: * @param obs is an observer of deploy events.
135: */
136: public void removeDeploymentObserver(DeploymentObserver obs) {
137: mObservers.remove(obs);
138: }
139:
140: }
|