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: * @(#)BindingComponentContext.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * BindingComponentContext.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: * Created on November 4, 2004, 12:49 PM
037: */package com.sun.jbi.internal.security;
038:
039: import com.sun.jbi.EnvironmentContext;
040: import com.sun.jbi.StringTranslator;
041:
042: /**
043: *
044: * @author Sun Microsystems, Inc.
045: */
046: public class BindingComponentContext implements
047: com.sun.jbi.internal.security.ComponentContext {
048: /** The wrapped ComponentContext. */
049: private com.sun.jbi.component.ComponentContext mComponentContext;
050:
051: /**
052: * The EnvironmentContext to be used for getting the StringTranslator.
053: */
054: private EnvironmentContext mEnvCtx;
055:
056: /**
057: * Creates a new instance of BindingComponentContext.
058: *
059: * @param ctx is the ComponentContext
060: * @param envCtx is the SecurityService Environment Context, this is used
061: * purely for getting the String Translator.
062: */
063: public BindingComponentContext(
064: com.sun.jbi.component.ComponentContext ctx,
065: EnvironmentContext envCtx) {
066: mComponentContext = ctx;
067: mEnvCtx = envCtx;
068: }
069:
070: /**
071: * Get the StringTranslator required for i18N based on the package name.
072: *
073: * @param packageName is the name of the package
074: * @return the StringTranslator for the package
075: */
076: public StringTranslator getStringTranslator(String packageName) {
077: return mEnvCtx.getStringTranslator(packageName);
078: }
079:
080: /**
081: * Get the StringTranslator required for i18N based on the objects package name.
082: *
083: * @param object is the Object.
084: * @return the StringTranslator for the object.
085: */
086: public StringTranslator getStringTranslatorFor(Object object) {
087: return mEnvCtx.getStringTranslatorFor(object);
088: }
089:
090: /**
091: * Get the Component Id of the Binding Component.
092: *
093: * @return the ComponentId as String
094: */
095: public String getComponentName() {
096: if (mComponentContext != null) {
097: return mComponentContext.getComponentName();
098: }
099: return "dunno";
100: }
101:
102: /**
103: * Get the SecurityHandler.
104: *
105: * @return the SecurityHandler instance for the component.
106: */
107: public com.sun.jbi.binding.security.SecurityHandler getSecurityHandler() {
108: return mComponentContext.getSecurityHandler();
109: }
110:
111: }
|